ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2026-01-24 00:14:48
Exec Total Coverage
Lines: 9712 13434 72.3%
Functions: 116 143 81.1%
Branches: 7568 12961 58.4%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "base/misctypes.h"
45 #include "base/initdata.h"
46 #include "advanced_music.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 442 std::map<int32_t, script_slot_data > ffcmap;
92 442 std::map<int32_t, script_slot_data > globalmap;
93 442 std::map<int32_t, script_slot_data > genericmap;
94 442 std::map<int32_t, script_slot_data > itemmap;
95 442 std::map<int32_t, script_slot_data > npcmap;
96 442 std::map<int32_t, script_slot_data > ewpnmap;
97 442 std::map<int32_t, script_slot_data > lwpnmap;
98 442 std::map<int32_t, script_slot_data > playermap;
99 442 std::map<int32_t, script_slot_data > dmapmap;
100 442 std::map<int32_t, script_slot_data > screenmap;
101 442 std::map<int32_t, script_slot_data > itemspritemap;
102 442 std::map<int32_t, script_slot_data > comboscriptmap;
103 442 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 241 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 241 return p_iputw(section_version, f);
115 }
116
117 15264 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 15264 return p_igetw(&unused, f);
121 }
122
123 22013 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 22006 times.
22013 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 7 output = fmt::format("{} --{}", slotname, scriptname);
129 7 break;
130 22006 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 22006 output = fmt::format("{} {}", slotname, scriptname);
133 22006 }
134 22013 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337
338 zquestheader tempheader{};
339
340 if(!f)
341 {
342 return qe_invalid;
343 }
344
345 ret=readheader(f, &tempheader);
346
347 if(ret)
348 {
349 return ret;
350 }
351
352 map_count=temp_map_count;
353 *version=tempheader.zelda_version;
354 *build=tempheader.build;
355 return 0;
356 }
357
358
359 bool find_section(PACKFILE *f, int32_t section_id_requested)
360 {
361
362 if(!f)
363 {
364 return false;
365 }
366
367 int32_t section_id_read;
368 bool catchup=false;
369 word dummy;
370 byte tempbyte;
371 char tempbuf[65536];
372
373
374 switch(section_id_requested)
375 {
376 case ID_RULES:
377 case ID_STRINGS:
378 case ID_MISC:
379 case ID_TILES:
380 case ID_COMBOS:
381 case ID_CSETS:
382 case ID_MAPS:
383 case ID_DMAPS:
384 case ID_DOORS:
385 case ID_ITEMS:
386 case ID_WEAPONS:
387 case ID_COLORS:
388 case ID_ICONS:
389 case ID_INITDATA:
390 case ID_GUYS:
391 case ID_MIDIS:
392 case ID_CHEATS:
393 break;
394
395 default:
396 al_trace("Bad section requested!\n");
397 return false;
398 break;
399 }
400
401 dword section_size;
402
403 //section id
404 if(!p_mgetl(&section_id_read,f))
405 {
406 return false;
407 }
408
409 while(!pack_feof(f))
410 {
411 switch(section_id_read)
412 {
413 case ID_RULES:
414 case ID_STRINGS:
415 case ID_MISC:
416 case ID_TILES:
417 case ID_COMBOS:
418 case ID_CSETS:
419 case ID_MAPS:
420 case ID_DMAPS:
421 case ID_DOORS:
422 case ID_ITEMS:
423 case ID_WEAPONS:
424 case ID_COLORS:
425 case ID_ICONS:
426 case ID_INITDATA:
427 case ID_GUYS:
428 case ID_MIDIS:
429 case ID_CHEATS:
430 catchup=false;
431 break;
432
433 default:
434 break;
435 }
436
437
438 while(catchup)
439 {
440 //section id
441 section_id_read=(section_id_read<<8);
442
443 if(!p_getc(&tempbyte,f))
444 {
445 return false;
446 }
447
448 section_id_read+=tempbyte;
449 }
450
451 if(section_id_read==section_id_requested)
452 {
453 return true;
454 }
455 else
456 {
457 //section version info
458 if(!p_igetw(&dummy,f))
459 {
460 return false;
461 }
462
463 if(!p_igetw(&dummy,f))
464 {
465 return false;
466 }
467
468 //section size
469 if(!p_igetl(&section_size,f))
470 {
471 return false;
472 }
473
474 //pack_fseek(f, section_size);
475 while(section_size>65535)
476 {
477 pfread(tempbuf,65535,f);
478 tempbuf[65535]=0;
479 section_size-=65535;
480 }
481
482 if(section_size>0)
483 {
484 pfread(tempbuf,section_size,f);
485 tempbuf[section_size]=0;
486 }
487 }
488
489 //section id
490 if(!p_mgetl(&section_id_read,f))
491 {
492 return false;
493 }
494 }
495
496 return false;
497 }
498
499
500
501
502
503 bool valid_zqt(PACKFILE *f)
504 {
505
506 //word tiles_used;
507 //word combos_used;
508 //open the file
509 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
510 if(!f)
511 return false;
512
513 //for now, everything else is valid
514 return true;
515
516 /*int16_t version;
517 byte build;
518
519 //read the version and make sure it worked
520 if(!p_igetw(&version,f))
521 {
522 goto error;
523 }
524
525 //read the build and make sure it worked
526 if(!p_getc(&build,f))
527 goto error;
528
529 //read the tile info and make sure it worked
530 if(!p_igetw(&tiles_used,f))
531 {
532 goto error;
533 }
534
535 for (int32_t i=0; i<tiles_used; i++)
536 {
537 if(!pfread(trashbuf,tilesize(tf4Bit),f))
538 {
539 goto error;
540 }
541 }
542
543 //read the combo info and make sure it worked
544 if(!p_igetw(&combos_used,f))
545 {
546 goto error;
547 }
548 for (int32_t i=0; i<combos_used; i++)
549 {
550 if(!pfread(trashbuf,sizeof(newcombo),f))
551 {
552 goto error;
553 }
554 }
555
556 //read the palette info and make sure it worked
557 for (int32_t i=0; i<48; i++)
558 {
559 if(!pfread(trashbuf,newpdTOTAL,f))
560 {
561 goto error;
562 }
563 }
564 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
565 {
566 goto error;
567 }
568 for (int32_t i=0; i<MAXLEVELS; i++)
569 {
570 if(!pfread(trashbuf,PALNAMESIZE,f))
571 {
572 goto error;
573 }
574 }
575
576 //read the sprite info and make sure it worked
577 for (int32_t i=0; i<MAXITEMS; i++)
578 {
579 if(!pfread(trashbuf,sizeof(itemdata),f))
580 {
581 goto error;
582 }
583 }
584
585 for (int32_t i=0; i<MAXWPNS; i++)
586 {
587 if(!pfread(trashbuf,sizeof(wpndata),f))
588 {
589 goto error;
590 }
591 }
592
593 //read the triforce pieces info and make sure it worked
594 for (int32_t i=0; i<8; ++i)
595 {
596 if(!p_getc(&trashbuf,f))
597 {
598 goto error;
599 }
600 }
601
602
603
604 //read the game icons info and make sure it worked
605 for (int32_t i=0; i<4; ++i)
606 {
607 if(!p_igetw(&trashbuf,f))
608 {
609 goto error;
610 }
611 }
612
613 //read the misc colors info and map styles info and make sure it worked
614 if(!pfread(trashbuf,sizeof(zcolors),f))
615 {
616 goto error;
617 }
618
619 //read the template screens and make sure it worked
620 byte num_maps;
621 if(!p_getc(&num_maps,f))
622 {
623 goto error;
624 }
625 for (int32_t i=0; i<TEMPLATES; i++)
626 {
627 if(!pfread(trashbuf,sizeof(mapscr),f))
628 {
629 goto error;
630 }
631 }
632 if (num_maps>1) //dungeon templates
633 {
634 for (int32_t i=0; i<TEMPLATES; i++)
635 {
636 if(!pfread(trashbuf,sizeof(mapscr),f))
637 {
638 goto error;
639 }
640 }
641 }
642
643 //yay! it worked! close the file and say everything was ok.
644 pack_fclose(f);
645 return true;
646
647 error:
648 pack_fclose(f);
649 return false;*/
650 }
651
652 bool valid_zqt(const char *filename)
653 {
654 PACKFILE *f=NULL;
655 bool isvalid;
656 int32_t error;
657 f=open_quest_file(&error, filename, false);
658
659 if(!f)
660 {
661 // setPackfilePassword(NULL);
662 return false;
663 }
664
665 isvalid=valid_zqt(f);
666
667 clear_quest_tmpfile();
668 pack_fclose(f);
669
670 // setPackfilePassword(NULL);
671 return isvalid;
672 }
673
674 /*
675 .qst file history
676
677 .qst files have always been compressed using allegro's packfiles.
678
679 At some point, an encoding layer was added. The two layers look like this:
680
681 1) The top layer is from us. See decode_file_007.
682 [0-24] Preamble "Zelda Classic Quest File"
683 [25-28] Initial decoding seed value.
684 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
685 [last 4] Checksum
686
687 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
688 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
689 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
690 The oldest quests skip the password part.
691
692 Simply, the job of this function is to peel away the top layer.
693
694 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
695 in opening and saving files. There is no version field, so they decryption key is
696 found via trial-by-error (very slow!)
697
698 There are other file types of interest:
699 - .zqt: quest template files, skips top-layer encryption pass
700 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
701 - .qu?: same as above. automated backup files
702 - .qb?: same as above. automated backup files
703 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
704
705 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
706 files are now "slh!.AG ZC Enhanced Quest File".
707 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
708 */
709 832 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
710 {
711
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if (show_progress)
712 {
713 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
714 }
715
716 832 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
717
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 495 times.
832 if (unencrypted_result.decoded_pf)
718 337 return unencrypted_result.decoded_pf;
719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 495 times.
495 if (unencrypted_result.not_found)
720 {
721 *open_error = qe_notfound;
722 return nullptr;
723 }
724
725 // Everything below here is legacy code - recently saved quest files will have
726 // returned by now.
727 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
728
729 // Note: although this is primarily for loading .qst files, it can also handle all of the
730 // file types mentioned in the comment above. No need to be told if the file being loaded
731 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
732 495 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
733 495 bool compressed = unencrypted_result.compressed;
734 495 bool encrypted = unencrypted_result.encrypted;
735
736 char tmpfilename[L_tmpnam];
737 495 temp_name(tmpfilename);
738 char percent_done[30];
739 495 int32_t current_method=0;
740
741 PACKFILE *f;
742 495 const char *passwd= encrypted ? datapwd : "";
743
744 // oldquest flag is set when an unencrypted qst file is suspected.
745 495 bool oldquest = false;
746 int32_t ret;
747
748
1/2
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
495 if(strcmp(filename, "default.qst")!=0)
749 {
750 495 box_out(filename);
751 495 }
752 else
753 {
754 box_out("new quest"); // Or whatever
755 }
756 495 box_out("...");
757 495 box_eol();
758 495 box_eol();
759
760
1/2
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
495 if(encrypted)
761 {
762 495 box_out("Decrypting...");
763 495 box_save_x();
764 495 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
765
766
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 63 times.
495 if(ret)
767 {
768
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
769 {
770 case 1:
771 box_out("error.");
772 box_eol();
773 box_end(true);
774 *open_error=qe_notfound;
775 return NULL;
776
777 case 2:
778 box_out("error.");
779 box_eol();
780 box_end(true);
781 *open_error=qe_internal;
782 return NULL;
783 // be sure not to delete tmpfilename now...
784 }
785
786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
787 {
788 63 current_method++;
789 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
790 63 box_out(percent_done);
791 63 box_load_x();
792 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
793 63 }
794
795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
796 {
797 63 current_method++;
798 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
799 63 box_out(percent_done);
800 63 box_load_x();
801 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
802 63 }
803
804
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
805 {
806 18 current_method++;
807 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
808 18 box_out(percent_done);
809 18 box_load_x();
810 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
811 18 }
812
813
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
814 {
815 12 current_method++;
816 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
817 12 box_out(percent_done);
818 12 box_load_x();
819 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
820 12 }
821
822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
823 {
824 oldquest = true;
825 passwd="";
826 }
827 63 }
828
829 495 box_out("okay.");
830 495 box_eol();
831 495 }
832 else
833 {
834 oldquest = true;
835 }
836
837 495 box_out("Opening...");
838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 495 times.
495 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
839
1/2
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
495 if(!f)
840 {
841 if((compressed==1)&&(errno==EDOM))
842 {
843 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
844 }
845
846 if(!f)
847 {
848 if(!oldquest)
849 {
850 delete_file(tmpfilename);
851 }
852 box_out("error.");
853 box_eol();
854 box_end(true);
855 *open_error=qe_invalid;
856 return NULL;
857 }
858 }
859
860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 495 times.
495 if(!oldquest)
861 {
862 495 delete_file(tmpfilename);
863 495 }
864
865 495 box_out("okay.");
866 495 box_eol();
867
868 495 return f;
869 832 }
870
871 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
872 {
873 PACKFILE *f=NULL;
874 int32_t open_error=0;
875
876 if (Header->templatepath[0] != 0)
877 {
878 // TODO: should be safe to remove this, no one seems to use custom quest templates.
879 filename=Header->templatepath;
880 }
881
882 f=open_quest_file(&open_error, filename, false);
883
884 if(!f)
885 {
886 return NULL;
887 }
888
889 if(validate)
890 {
891 if(!valid_zqt(f))
892 {
893 displayinfo("Error", "Invalid Quest Template");
894 pack_fclose(f);
895 clear_quest_tmpfile();
896 return NULL;
897 }
898 }
899
900 return f;
901 }
902
903 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
904 {
905 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
906 if (get_app_id() == App::zelda)
907 assert(section_id == ID_TILES);
908
909 combosread=false;
910 mapsread=false;
911 fixffcs=false;
912
913 switch(section_id)
914 {
915 case ID_RULES:
916 case ID_STRINGS:
917 case ID_MISC:
918 case ID_TILES:
919 case ID_COMBOS:
920 case ID_CSETS:
921 case ID_MAPS:
922 case ID_DMAPS:
923 case ID_DOORS:
924 case ID_ITEMS:
925 case ID_WEAPONS:
926 case ID_COLORS:
927 case ID_ICONS:
928 case ID_INITDATA:
929 case ID_GUYS:
930 case ID_MIDIS:
931 case ID_CHEATS:
932 case ID_ITEMDROPSETS:
933 case ID_FAVORITES:
934 break;
935
936 default:
937 return false;
938 break;
939 }
940
941 int32_t ret;
942 word version, build;
943 PACKFILE *f=NULL;
944
945 //why is this here?
946 /*
947 if(colordata==NULL)
948 return false;
949 */
950
951 //setPackfilePassword(datapwd);
952 f=open_quest_template(Header, filename, validate);
953
954 if(!f) //no file, nothing to delete
955 {
956 // setPackfilePassword(NULL);
957 return false;
958 }
959
960 ret=get_version_and_build(f, &version, &build);
961
962 if(ret||(version==0))
963 {
964 pack_fclose(f);
965 clear_quest_tmpfile();
966
967 // setPackfilePassword(NULL);
968 return false;
969 }
970
971 if(!find_section(f, section_id))
972 {
973 al_trace("Can't find section!\n");
974 pack_fclose(f);
975 clear_quest_tmpfile();
976
977 //setPackfilePassword(NULL);
978 return false;
979 }
980
981 switch(section_id)
982 {
983 case ID_RULES:
984 //rules
985 ret=readrules(f, Header);
986 break;
987
988 case ID_STRINGS:
989 //strings
990 ret=readstrings(f, Header);
991 break;
992
993 case ID_MISC:
994 //misc data
995 ret=readmisc(f, Header, Misc);
996 break;
997
998 case ID_TILES:
999 //tiles
1000 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1001 break;
1002
1003 case ID_COMBOS:
1004 //combos
1005 clear_combos();
1006 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1007 combosread=true;
1008 break;
1009
1010 case ID_COMBOALIASES:
1011 //combos
1012 ret=readcomboaliases(f, Header, version, build);
1013 break;
1014
1015 case ID_CSETS:
1016 //color data
1017 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1018 break;
1019
1020 case ID_MAPS:
1021 //maps
1022 ret=readmaps(f, Header);
1023 mapsread=true;
1024 break;
1025
1026 case ID_DMAPS:
1027 //dmaps
1028 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1029 break;
1030
1031 case ID_DOORS:
1032 //door combo sets
1033 ret=readdoorcombosets(f, Header);
1034 break;
1035
1036 case ID_ITEMS:
1037 //items
1038 ret=readitems(f, version, build);
1039 break;
1040
1041 case ID_WEAPONS:
1042 //weapons
1043 ret=readweapons(f, Header);
1044 break;
1045
1046 case ID_COLORS:
1047 //misc. colors
1048 ret=readmisccolors(f, Header, Misc);
1049 break;
1050
1051 case ID_ICONS:
1052 //game icons
1053 ret=readgameicons(f, Header, Misc);
1054 break;
1055
1056 case ID_INITDATA:
1057 //initialization data
1058 ret=readinitdata(f, Header);
1059 break;
1060
1061 case ID_GUYS:
1062 //guys
1063 ret=readguys(f, Header);
1064 break;
1065
1066 case ID_MIDIS:
1067 //midis
1068 ret=readmidis(f, Header, tunes);
1069 break;
1070
1071 case ID_CHEATS:
1072 //cheat codes
1073 ret=readcheatcodes(f, Header);
1074 break;
1075
1076 case ID_ITEMDROPSETS:
1077 //item drop sets
1078 // Why is this one commented out?
1079 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1080 break;
1081
1082 case ID_FAVORITES:
1083 // favorite combos and aliases
1084 ret=readfavorites(f, version);
1085 break;
1086
1087 default:
1088 ret=-1;
1089 break;
1090 }
1091
1092 pack_fclose(f);
1093 clear_quest_tmpfile();
1094
1095 //setPackfilePassword(NULL);
1096 if(!ret)
1097 {
1098 return true;
1099 }
1100
1101 return false;
1102 }
1103
1104 bool init_tiles_for_190(bool validate, zquestheader *Header)
1105 {
1106 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1107 }
1108
1109 bool init_tiles(bool validate, zquestheader *Header)
1110 {
1111 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1112 }
1113
1114 bool init_combos(bool validate, zquestheader *Header)
1115 {
1116 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1117 }
1118
1119 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1120 {
1121 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1122 }
1123
1124 832 void init_spritelists()
1125 {
1126
2/2
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 215 times.
832 if(FFCore.quest_format[vZelda] < 0x255)
1127 {
1128 617 guys.setMax(255);
1129 617 items.setMax(255);
1130 617 Ewpns.setMax(255);
1131 617 Lwpns.setMax(255);
1132 617 chainlinks.setMax(255);
1133 617 decorations.setMax(255);
1134 617 particles.setMax(255);
1135 617 }
1136 else
1137 {
1138 215 guys.setMax(255);
1139 215 items.setMax(255);
1140 215 Ewpns.setMax(255);
1141 215 Lwpns.setMax(255);
1142 215 chainlinks.setMax(255);
1143 215 decorations.setMax(255);
1144 215 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1145 }
1146 832 }
1147
1148 326 bool reset_items(bool validate, zquestheader *Header)
1149 {
1150 326 bool ret = true;
1151
1/2
✓ Branch 0 taken 326 times.
✗ Branch 1 not taken.
326 if (get_app_id() == App::zquest)
1152 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1153
1154
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 83456 times.
83782 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1155
1156 326 return ret;
1157 }
1158
1159 bool reset_guys()
1160 {
1161 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1162 init_guys(V_GUYS);
1163 return true;
1164 }
1165
1166 bool reset_wpns(bool validate, zquestheader *Header)
1167 {
1168 bool ret = true;
1169 if (get_app_id() == App::zquest)
1170 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1171
1172 for(int32_t i=0; i<MAXWPNS; i++)
1173 reset_weaponname(i);
1174
1175 return ret;
1176 }
1177
1178 bool reset_mapstyles(bool validate, miscQdata *Misc)
1179 {
1180 Misc->colors.blueframe_tile = 20044;
1181 Misc->colors.blueframe_cset = 0;
1182 Misc->colors.triforce_tile = 23461;
1183 Misc->colors.triforce_cset = 1;
1184 Misc->colors.triframe_tile = 18752;
1185 Misc->colors.triframe_cset = 1;
1186 Misc->colors.overworld_map_tile = 16990;
1187 Misc->colors.overworld_map_cset = 2;
1188 Misc->colors.HCpieces_tile = 21160;
1189 Misc->colors.HCpieces_cset = 8;
1190 Misc->colors.dungeon_map_tile = 19651;
1191 Misc->colors.dungeon_map_cset = 8;
1192 return true;
1193 }
1194
1195 1299893 int32_t read_weap_data(weapon_data& data, PACKFILE* f)
1196 {
1197 word v_weapon_data;
1198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1299893 times.
1299893 if(!p_igetw(&v_weapon_data,f))
1199 return qe_invalid;
1200
1201
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetw(&(data.flags), f))
1202 return qe_invalid;
1203
1204
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.moveflags), f))
1205 return qe_invalid;
1206
1207
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetw(&(data.wflags), f))
1208 return qe_invalid;
1209
1210
2/2
✓ Branch 0 taken 6499465 times.
✓ Branch 1 taken 1299893 times.
7799358 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
1211 {
1212
1/2
✓ Branch 0 taken 6499465 times.
✗ Branch 1 not taken.
6499465 if (!p_getc(&(data.burnsprs[q]), f))
1213 return qe_invalid;
1214
1/2
✓ Branch 0 taken 6499465 times.
✗ Branch 1 not taken.
6499465 if (!p_getc(&(data.light_rads[q]), f))
1215 return qe_invalid;
1216 6499465 }
1217
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.glow_shape), f))
1218 return qe_invalid;
1219
1220
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.override_flags), f))
1221 return qe_invalid;
1222
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.tilew), f))
1223 return qe_invalid;
1224
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.tileh), f))
1225 return qe_invalid;
1226
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.hxsz), f))
1227 return qe_invalid;
1228
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.hysz), f))
1229 return qe_invalid;
1230
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.hzsz), f))
1231 return qe_invalid;
1232
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.hxofs), f))
1233 return qe_invalid;
1234
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.hyofs), f))
1235 return qe_invalid;
1236
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.xofs), f))
1237 return qe_invalid;
1238
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.yofs), f))
1239 return qe_invalid;
1240
1241
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetzf(&(data.step), f))
1242 return qe_invalid;
1243
1244
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.unblockable), f))
1245 return qe_invalid;
1246
1247
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetl(&(data.timeout), f))
1248 return qe_invalid;
1249
1250
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.imitate_weapon), f))
1251 return qe_invalid;
1252
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.default_defense), f))
1253 return qe_invalid;
1254
1255
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.lift_level), f))
1256 return qe_invalid;
1257
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_getc(&(data.lift_time), f))
1258 return qe_invalid;
1259
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if (!p_igetzf(&(data.lift_height), f))
1260 return qe_invalid;
1261
1262
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if(!p_igetw(&(data.script), f))
1263 return qe_invalid;
1264
2/2
✓ Branch 0 taken 10399144 times.
✓ Branch 1 taken 1299893 times.
11699037 for(uint q = 0; q < 8; ++q)
1265
1/2
✓ Branch 0 taken 10399144 times.
✗ Branch 1 not taken.
10399144 if(!p_igetl(&(data.initd[q]), f))
1266 return qe_invalid;
1267
1/2
✓ Branch 0 taken 1299893 times.
✗ Branch 1 not taken.
1299893 if(!p_igetw(&(data.pierce_count), f))
1268 return qe_invalid;
1269 1299893 return 0;
1270 1299893 }
1271
1272 445 int32_t get_qst_buffers()
1273 {
1274 445 TheMaps.resize(MAPSCRS);
1275 445 old_combo_pages.resize(MAPSCRS);
1276 445 map_infos.resize(1);
1277
1278 445 Z_message("OK\n");
1279
1280 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1281 // (Shoelace's "Hero of Dreams" uses 1415.)
1282 // So let's be a bit generous and allow 4096 initially.
1283 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1284 // I tested it and it worked without flaw on 6/6/11. - L.
1285 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1286 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1287 // See https://discord.com/channels/876899628556091432/992984989073416242
1288 445 msg_strings_size = 8192;
1289
1290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445 times.
445 MsgStrings = new MsgStr[msg_strings_size];
1291
1292 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1293
2/2
✓ Branch 0 taken 3645440 times.
✓ Branch 1 taken 445 times.
3645885 for(auto q = 0; q < msg_strings_size; ++q)
1294 {
1295 3645440 MsgStrings[q].clear();
1296 3645440 }
1297
1298
4/6
✓ Branch 0 taken 227840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227395 times.
✓ Branch 3 taken 445 times.
✓ Branch 4 taken 445 times.
✗ Branch 5 not taken.
227840 if((DMaps=new dmap[MAXDMAPS])==NULL)
1299 return 0;
1300
1301
1302
1303 445 combobuf.clear();
1304 445 combobuf.resize(MAXCOMBOS);
1305
1306
1307
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1308 return 0;
1309
1310 445 free_newtilebuf();
1311
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1312 return 0;
1313
1314 445 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1315 //Z_message("Performed memset on tiles\n");
1316 445 clear_tiles(newtilebuf);
1317 //Z_message("Performed clear_tiles()\n");
1318
1319
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 15 times.
445 if (get_app_id() == App::zquest)
1320 {
1321
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1322 return 0;
1323
1324 15 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1325 15 clear_tiles(grabtilebuf);
1326 15 }
1327
1328
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((trashbuf=(byte*)malloc(100000))==NULL)
1329 return 0;
1330
1331 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1332 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1333 // fixed by ensuring there's actually itemdata there.
1334 // If you change this, be sure to update del_qst_buffers, too.
1335
1336
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1337 return 0;
1338
1339
2/2
✓ Branch 0 taken 114365 times.
✓ Branch 1 taken 445 times.
114810 for(size_t q = 0; q < MAXITEMS+1; ++q)
1340 114365 itemsbuf[q].clear();
1341 445 itemsbuf++;
1342
1343
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1344 return 0;
1345
1346 445 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1347
1348
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1349 return 0;
1350
1351
2/2
✓ Branch 0 taken 227840 times.
✓ Branch 1 taken 445 times.
228285 for(size_t q = 0; q < MAXGUYS; ++q)
1352 227840 guysbuf[q].clear();
1353
1354
1/2
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
445 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1355 return 0;
1356
1357 445 return 1;
1358 445 }
1359
1360
1361 782 void free_newtilebuf()
1362 {
1363
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 442 times.
782 if(newtilebuf)
1364 {
1365
2/2
✓ Branch 0 taken 72930000 times.
✓ Branch 1 taken 340 times.
72930340 for(int32_t i=0; i<NEWMAXTILES; i++)
1366
2/2
✓ Branch 0 taken 643500 times.
✓ Branch 1 taken 72286500 times.
145216500 if(newtilebuf[i].data)
1367 72286500 free(newtilebuf[i].data);
1368
1369 340 free(newtilebuf);
1370 340 newtilebuf = 0;
1371 340 }
1372 782 }
1373
1374 337 void free_grabtilebuf()
1375 {
1376
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 11 times.
337 if (get_app_id() == App::zquest)
1377 {
1378
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1379 {
1380
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1382
1383 11 free(grabtilebuf);
1384 11 grabtilebuf = 0;
1385 11 }
1386 11 }
1387 337 }
1388
1389 337 void del_qst_buffers()
1390 {
1391
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 337 times.
✗ Branch 3 not taken.
337 if(MsgStrings) delete[] MsgStrings;
1392
1393
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 337 times.
✗ Branch 3 not taken.
337 if (DMaps) delete[] DMaps;
1394
1395 337 combobuf.clear();
1396
1397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(colordata) free(colordata);
1398
1399 337 free_newtilebuf();
1400 337 free_grabtilebuf();
1401
1402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(trashbuf) free(trashbuf);
1403
1404 // See get_qst_buffers
1405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(itemsbuf)
1406 {
1407 337 itemsbuf--;
1408 337 free(itemsbuf);
1409 337 }
1410
1411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(wpnsbuf) free(wpnsbuf);
1412
1413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(guysbuf) free(guysbuf);
1414
1415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(combo_class_buf) free(combo_class_buf);
1416 337 }
1417
1418 18 bool init_palnames()
1419 {
1420 // if(palnames==NULL)
1421 // return false;
1422
1423
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1424 {
1425
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1426 {
1427 case 0:
1428 18 sprintf(palnames[x],"Overworld");
1429 18 break;
1430
1431 case 10:
1432 18 sprintf(palnames[x],"Caves");
1433 18 break;
1434
1435 case 11:
1436 18 sprintf(palnames[x],"Passageways");
1437 18 break;
1438
1439 default:
1440 9162 sprintf(palnames[x],"%c",0);
1441 9162 break;
1442 }
1443 9216 }
1444
1445 18 return true;
1446 }
1447
1448 100662 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1449 {
1450 void *p;
1451
1452
1/2
✓ Branch 0 taken 100662 times.
✗ Branch 1 not taken.
100662 p = _AL_MALLOC(MAX(size, alloc_size));
1453
1454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100662 times.
100662 if(!p)
1455 {
1456 return NULL;
1457 }
1458
1459
1/2
✓ Branch 0 taken 100662 times.
✗ Branch 1 not taken.
100662 if(!pfread(p,size,f))
1460 {
1461 _AL_FREE(p);
1462 return NULL;
1463 }
1464
1465
1/2
✓ Branch 0 taken 100662 times.
✗ Branch 1 not taken.
100662 if(pack_ferror(f))
1466 {
1467 _AL_FREE(p);
1468 return NULL;
1469 }
1470
1471 100662 return p;
1472 100662 }
1473
1474 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1475 static const byte* legacy_skip_flags;
1476
1477 /* read_midi:
1478 * Reads MIDI data from a datafile (this is not the same thing as the
1479 * standard midi file format).
1480 */
1481 10331 static MIDI *read_midi(PACKFILE *f)
1482 {
1483 MIDI *m;
1484 int32_t c;
1485 10331 int16_t divisions=0;
1486 10331 int32_t len=0;
1487
1488 10331 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1489
1490
1/2
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
10331 if(!m) return NULL;
1491
1492
2/2
✓ Branch 0 taken 330592 times.
✓ Branch 1 taken 10331 times.
340923 for(c=0; c<MIDI_TRACKS; c++)
1493 {
1494 330592 m->track[c].len = 0;
1495 330592 m->track[c].data = NULL;
1496 330592 }
1497
1498 10331 p_mgetw(&divisions,f);
1499 10331 m->divisions=divisions;
1500
1501
2/2
✓ Branch 0 taken 330592 times.
✓ Branch 1 taken 10331 times.
340923 for(c=0; c<MIDI_TRACKS; c++)
1502 {
1503 330592 p_mgetl(&len,f);
1504 330592 m->track[c].len=len;
1505
1506
2/2
✓ Branch 0 taken 229930 times.
✓ Branch 1 taken 100662 times.
330592 if(m->track[c].len > 0)
1507 {
1508 100662 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1509
1510
1/2
✓ Branch 0 taken 100662 times.
✗ Branch 1 not taken.
100662 if(!m->track[c].data)
1511 {
1512 destroy_midi(m);
1513 return NULL;
1514 }
1515 100662 }
1516 330592 }
1517
1518 LOCK_DATA(m, sizeof(MIDI));
1519
1520
2/2
✓ Branch 0 taken 330592 times.
✓ Branch 1 taken 10331 times.
340923 for(c=0; c<MIDI_TRACKS; c++)
1521 {
1522
2/2
✓ Branch 0 taken 100662 times.
✓ Branch 1 taken 229930 times.
330592 if(m->track[c].data)
1523 {
1524 LOCK_DATA(m->track[c].data, m->track[c].len);
1525 100662 }
1526 330592 }
1527
1528 10331 return m;
1529 10331 }
1530
1531 void clear_combo(int32_t i)
1532 {
1533 combobuf[i].clear();
1534 }
1535
1536 void clear_combos()
1537 {
1538 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1539 clear_combo(tmpcounter);
1540 }
1541
1542 void pack_combos()
1543 {
1544 int32_t di = 0;
1545
1546 for(int32_t si=0; si<1024; si+=2)
1547 combobuf[di++] = combobuf[si];
1548
1549 for(; di<1024; di++)
1550 clear_combo(di);
1551 }
1552
1553 int32_t doortranslations_u[9][4]=
1554 {
1555 {37,38,53,54},
1556 {37,38,39,40},
1557 {37,38,55,56},
1558 {37,38,39,40},
1559 {37,38,53,54},
1560 {37,38,53,54},
1561 {37,38,53,54},
1562 {7,8,23,24},
1563 {7,8,41,42}
1564 };
1565
1566 int32_t doortranslations_d[9][4]=
1567 {
1568 {117,118,133,134},
1569 {135,136,133,134},
1570 {119,120,133,134},
1571 {135,136,133,134},
1572 {117,118,133,134},
1573 {117,118,133,134},
1574 {117,118,133,134},
1575 {151,152,167,168},
1576 {137,138,167,168},
1577 };
1578
1579 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1580 int32_t doortranslations_l[9][6]=
1581 {
1582 {66,67,82,83,98,99},
1583 {66,68,82,84,98,100},
1584 {66,69,82,85,98,101},
1585 {66,68,82,84,98,100},
1586 {66,67,82,83,98,99},
1587 {66,67,82,83,98,99},
1588 {66,67,82,83,98,99},
1589 {64,65,80,81,96,97},
1590 {64,65,80,114,96,97},
1591 };
1592
1593 int32_t doortranslations_r[9][6]=
1594 {
1595
1596 {76,77,92,93,108,109},
1597 {75,77,91,93,107,109},
1598 {74,77,90,93,106,109},
1599 {75,77,91,93,107,109},
1600 {76,77,92,93,108,109},
1601 {76,77,92,93,108,109},
1602 {76,77,92,93,108,109},
1603 {78,79,94,95,110,111},
1604 {78,79,125,95,110,111},
1605 };
1606
1607 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1608 {
1609 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1610 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1611 }
1612
1613 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1614 {
1615 //these are here to bypass compiler warnings about unused arguments
1616 840750 map=map;
1617 840750 scr=scr;
1618 840750 pos=pos;
1619
1620 //what does this function do?
1621 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1622 840750 return 2;
1623 }
1624
1625 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1626 {
1627
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1628 {
1629 18423 return 0;
1630 }
1631
1632 4425 DoorComboSet tempdcs{};
1633
1634 //up
1635
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1636 {
1637
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1638 {
1639 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1640 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1641 159300 }
1642 39825 }
1643
1644 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1645 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1646 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1647 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1648 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1649 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1650
1651 //down
1652
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1653 {
1654
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1655 {
1656 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1657 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1658 159300 }
1659 39825 }
1660
1661 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1662
1663 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1664 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1665 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1666 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1667 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1668
1669 //left
1670 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1671
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1672 {
1673
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1674 {
1675 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1676 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1677 238950 }
1678 39825 }
1679
1680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1681 {
1682 if((j!=2)&&(j!=3))
1683 {
1684 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1685 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1686 }
1687 }
1688
1689 4425 tempdcs.bombdoorcombo_l[0]=0;
1690 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1691 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1692 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1693 4425 tempdcs.bombdoorcombo_l[2]=0;
1694 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1695 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1696 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1697
1698 //right
1699
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1700 {
1701
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1702 {
1703 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1704 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1705 238950 }
1706 39825 }
1707
1708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1709 {
1710 if((j!=2)&&(j!=3))
1711 {
1712 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1713 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1714 }
1715 }
1716
1717 4425 tempdcs.bombdoorcombo_r[0]=0;
1718 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1719 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1720 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1721 4425 tempdcs.bombdoorcombo_r[2]=0;
1722 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1723 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1724 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1725
1726 int32_t k;
1727
1728
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1729 {
1730
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1731 {
1732 4365 break;
1733 }
1734 5941 }
1735
1736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1737 {
1738 return 0;
1739 }
1740
1741
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1742 {
1743 60 DoorComboSets[k]=tempdcs;
1744 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1745 60 ++door_combo_set_count;
1746 60 }
1747
1748 4425 return k;
1749 /*
1750 doorcombo_u[9][4];
1751 doorcset_u[9][4];
1752 doorcombo_d[9][4];
1753 doorcset_d[9][4];
1754 doorcombo_l[9][6];
1755 doorcset_l[9][6];
1756 doorcombo_r[9][6];
1757 doorcset_r[9][6];
1758 bombdoorcombo_u[2];
1759 bombdoorcset_u[2];
1760 bombdoorcombo_d[2];
1761 bombdoorcset_d[2];
1762 bombdoorcombo_l[3];
1763 bombdoorcset_l[3];
1764 bombdoorcombo_r[3];
1765 bombdoorcset_r[3];
1766 walkthroughcombo[4];
1767 walkthroughcset[4];
1768 */
1769 22848 }
1770
1771 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1772 {
1773 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1774 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1775 }
1776
1777 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1778 {
1779
1780 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1781 }
1782
1783 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1784 {
1785 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1786 }
1787
1788
1789 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1790 {
1791 char temp_pwd[30];
1792 83 memset(temp_pwd,0,30);
1793
1794
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1795 {
1796 75 memcpy(temp_pwd,encrypted_pwd,30);
1797 75 temp_pwd[29]=0;
1798
1799
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1800 {
1801 2250 temp_pwd[i] -= pwdkey;
1802 2250 int32_t t=pwdkey>>15;
1803 2250 pwdkey = (pwdkey<<1)+t;
1804 2250 }
1805 75 }
1806
1807 83 memcpy(pwd,temp_pwd,30);
1808 83 }
1809
1810
1811 262 bool devpwd()
1812 {
1813 #ifdef _DEBUG
1814 return true;
1815 #endif
1816 #if DEVLEVEL > 3
1817 return true;
1818 #endif
1819
1/2
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
262 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1820 }
1821 bool check_questpwd(zquestheader *Header, char *pwd)
1822 {
1823 if(devpwd())
1824 return true;
1825 if((!strcmp(pwd, (char*)clavio)))
1826 return true;
1827 cvs_MD5Context ctx;
1828 uint8_t md5sum[16];
1829
1830 cvs_MD5Init(&ctx);
1831 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1832 cvs_MD5Final(md5sum, &ctx);
1833
1834 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1835 }
1836
1837 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1838 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1839 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1840
1841 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1842 {
1843 char keyfilename[2048];
1844 replace_extension(keyfilename, path, ext, 2047);
1845 if(!exists(keyfilename))
1846 return false;
1847 bool ret = false;
1848
1849 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1850 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1851 char msg[80] = {0};
1852 pfread(msg, 80, fp);
1853 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1854 {
1855 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1856 pack_fclose(fp);
1857 return false;
1858 }
1859 int16_t ver;
1860 byte bld;
1861 p_igetw(&ver, fp);
1862 p_getc(&bld, fp);
1863 pfread(password, QSTPWD_LEN, fp, true);
1864 if(hashed)
1865 {
1866 char unhashed_pw[QSTPWD_LEN] = {0};
1867
1868 char hashmap = 'Z';
1869 hashmap += 'Q';
1870 hashmap += 'U';
1871 hashmap += 'E';
1872 hashmap += 'S';
1873 hashmap += 'T';
1874
1875 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1876 unhashed_pw[q] = password[q] - hashmap;
1877
1878 ret = check_questpwd(Header, unhashed_pw);
1879 }
1880 else ret = check_questpwd(Header, password);
1881 pack_fclose(fp);
1882 zprint2("Found %s Key File '%s' (%s access)\n",
1883 typestr, keyfilename, ret ? "valid" : "invalid");
1884 return ret;
1885 }
1886
1887 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1888 {
1889 char exedir[PATH_MAX] = {0};
1890 extract_name(path, exedir, FILENAMEALL);
1891 char const* paths[] = {path, exedir};
1892 for(uint keyty : types)
1893 {
1894 if(keyty >= KEYFILE_NUMTY)
1895 continue;
1896 for(char const* p : paths)
1897 {
1898 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1899 return true;
1900 }
1901 }
1902 return false;
1903 }
1904
1905 498 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1906 {
1907 498 zprint2("\n");
1908 498 zprint2("[QUEST METADATA]\n");
1909
1/2
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
498 if(path)
1910 498 zprint2("Path: %s\n", path);
1911
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 128 times.
498 if(tempheader.title[0])
1912 370 zprint2("Title: %s\n", tempheader.title);
1913 498 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1914
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 283 times.
498 if(tempheader.new_version_id_date_day)
1915 215 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1916
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 220 times.
498 if(tempheader.version[0])
1917 278 zprint2("Qst Version: %s\n", tempheader.version);
1918
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 128 times.
498 if(tempheader.author[0])
1919 370 zprint2("Author: %s\n", tempheader.author);
1920 498 zprint2("\n");
1921 498 }
1922 442 static bitstring midi_bitstr;
1923 844 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1924 {
1925 int32_t dummy;
1926 844 zquestheader tempheader{};
1927
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 12 times.
844 tempheader.filename = Header->filename;
1928 char dummybuf[80];
1929 byte temp_map_count;
1930 832 byte temp_midi_flags[32] = {0};
1931 word version;
1932 char temp_pwd[30], temp_pwd2[30];
1933 int16_t temp_pwdkey;
1934 cvs_MD5Context ctx;
1935 832 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1936
1937
1938
1939
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 832 times.
832 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1940 {
1941 Z_message("Unable to read header string\n");
1942 return qe_invalid;
1943 }
1944
1945 // check header
1946
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1947 {
1948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1949 {
1950 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1951 return qe_invalid;
1952 }
1953 24 }
1954
1955 832 int32_t templatepath_len=0;
1956
1957 832 tempheader.external_zinfo = false;
1958 832 read_zinfo = false;
1959
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 808 times.
832 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1960 {
1961 byte padding;
1962
1963
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1964 {
1965 return qe_invalid;
1966 }
1967
1968
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1969 {
1970 return qe_invalid;
1971 }
1972
1973 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1974
1975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1976 {
1977 return qe_version;
1978 }
1979
1980 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1981
1982
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1983 {
1984 return qe_invalid;
1985 }
1986
1987
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
1988 {
1989 return qe_obsolete;
1990 }
1991
1992
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.internal,f))
1993 {
1994 return qe_invalid;
1995 }
1996
1997
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.quest_number,f))
1998 {
1999 return qe_invalid;
2000 }
2001
2002 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2003
2004
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2005 {
2006 return qe_invalid;
2007 }
2008
2009
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
2010 {
2011 return qe_invalid;
2012 }
2013
2014 24 FFCore.quest_format[qMapCount] = temp_map_count;
2015
2016
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2017 {
2018 return qe_invalid;
2019 }
2020
2021
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2022 {
2023 return qe_invalid;
2024 }
2025
2026
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_midi_flags,4,f))
2027 {
2028 return qe_invalid;
2029 }
2030
2031
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2032 {
2033 return qe_invalid;
2034 }
2035
2036
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
2037 {
2038 return qe_invalid;
2039 }
2040
2041
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2042 {
2043 return qe_invalid;
2044 }
2045
2046
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
2047 {
2048 return qe_invalid;
2049 }
2050
2051
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
2052 {
2053 return qe_invalid;
2054 }
2055
2056
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2057 {
2058 return qe_invalid;
2059 }
2060 // These fields are expected to end in null bytes!
2061 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2062
2063
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2064 {
2065 return qe_invalid;
2066 }
2067 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2068
2069
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2070 {
2071 return qe_invalid;
2072 }
2073
2074
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2075 {
2076 return qe_invalid;
2077 }
2078
2079
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2080 {
2081 return qe_invalid;
2082 }
2083
2084 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2085
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2086
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2087
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2088
2089
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2090 {
2091 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2092 // Not anymore...
2093 memset(tempheader.minver,0,17);
2094 tempheader.build=0;
2095 tempheader.use_keyfile=0;
2096 memset(tempheader.old_foo, 0, 9);
2097 }
2098 else
2099 {
2100
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2101 {
2102 return qe_invalid;
2103 }
2104
2105
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2106 {
2107 return qe_invalid;
2108 }
2109
2110 24 FFCore.quest_format[vBuild] = tempheader.build;
2111
2112
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2113 {
2114 return qe_invalid;
2115 }
2116
2117
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2118 {
2119 return qe_invalid;
2120 }
2121 } // starting at minver
2122
2123
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2124 {
2125 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2126 6 }
2127 else
2128 {
2129
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2130 {
2131 return qe_invalid; // starting at rules3
2132 }
2133
2134
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2135 {
2136
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2137 12 }
2138 }
2139
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2140
2141
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2142
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2143 {
2144
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2145
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2146
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2147 18 }
2148
2149
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2150 {
2151 6 byte *mf=temp_midi_flags;
2152
2153
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2154 {
2155 4 mf=(byte*)dummybuf;
2156 4 }
2157
2158
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2159 {
2160 return qe_invalid; // starting at foo2
2161 }
2162
2163
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2164 {
2165 return qe_invalid; // starting at foo2
2166 }
2167 6 }
2168
2169
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2170
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2171 {
2172 18 memset(tempheader.templatepath,0,2048);
2173 18 }
2174 else
2175 {
2176 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2177 {
2178 return qe_invalid;
2179 }
2180 }
2181
2182
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2183
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2184 {
2185 24 tempheader.use_keyfile=0;
2186 24 }
2187 24 }
2188 else
2189 {
2190 //section id
2191
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_mgetl(&dummy,f))
2192 {
2193 return qe_invalid;
2194 }
2195
2196 //section version info
2197
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&version,f))
2198 {
2199 return qe_invalid;
2200 }
2201
2202
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if (version > V_HEADER)
2203 return qe_version;
2204
2205 808 FFCore.quest_format[vHeader] = version;
2206
2207
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&dummy,f))
2208 {
2209 return qe_invalid;
2210 }
2211
2212 //section size
2213
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetl(&dummy,f))
2214 {
2215 return qe_invalid;
2216 }
2217
2218 //finally... section data
2219
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&tempheader.zelda_version,f))
2220 {
2221 return qe_invalid;
2222 }
2223
2224 808 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2225
2226 //do some quick checking...
2227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(tempheader.zelda_version > ZELDA_VERSION)
2228 {
2229 return qe_version;
2230 }
2231
2232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2233 {
2234 return qe_invalid;
2235 }
2236
2237
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(bad_version(tempheader.zelda_version))
2238 {
2239 return qe_obsolete;
2240 }
2241
2242
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&tempheader.build,f))
2243 {
2244 return qe_invalid;
2245 }
2246
2247 808 FFCore.quest_format[vBuild] = tempheader.build;
2248
2249
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 749 times.
808 if(version<3)
2250 {
2251
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2252 {
2253 return qe_invalid;
2254 }
2255
2256
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2257 {
2258 return qe_invalid;
2259 }
2260
2261 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2262
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2263
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2264
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2265 59 }
2266 else
2267 {
2268
2/4
✓ Branch 0 taken 749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 749 times.
✗ Branch 3 not taken.
749 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2269 {
2270 return qe_invalid;
2271 }
2272 }
2273
2274
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&tempheader.internal,f))
2275 {
2276 return qe_invalid;
2277 }
2278
2279
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&tempheader.quest_number,f))
2280 {
2281 return qe_invalid;
2282 }
2283
2284 808 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2285
2286 808 size_t versz = version < 8 ? 9 : 16;
2287
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(tempheader.version,versz,f))
2288 {
2289 return qe_invalid;
2290 }
2291
2292 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2293 //needs to be copied as char[9] or stored as a s.str
2294
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(tempheader.minver,versz,f))
2295 {
2296 return qe_invalid;
2297 }
2298
2299 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2300
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2301 {
2302 return qe_invalid;
2303 }
2304 808 tempheader.title[sizeof(tempheader.title)-1] = 0;
2305
2306
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2307 {
2308 return qe_invalid;
2309 }
2310 808 tempheader.author[sizeof(tempheader.author)-1] = 0;
2311
2312
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&tempheader.use_keyfile,f))
2313 {
2314 return qe_invalid;
2315 }
2316
2317 /*
2318 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2319 {
2320 return qe_invalid;
2321 }
2322 */
2323
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2324 {
2325 return qe_invalid;
2326 }
2327
2328
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(&dummybuf,4,f))
2329 {
2330 return qe_invalid;
2331 }
2332
2333
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2334 {
2335 return qe_invalid;
2336 }
2337
2338
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(dummybuf,14,f))
2339 {
2340 return qe_invalid;
2341 }
2342
2343 808 templatepath_len=sizeof(tempheader.templatepath);
2344
2345
2/2
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 59 times.
808 if(version==1)
2346 {
2347 59 templatepath_len=280;
2348 59 }
2349
2350
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!pfread(tempheader.templatepath,templatepath_len,f))
2351 {
2352 return qe_invalid;
2353 }
2354
2355
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_getc(&temp_map_count,f))
2356 {
2357 return qe_invalid;
2358 }
2359
2360
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 593 times.
808 if(version>=4)
2361 {
2362
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.version_major,f))
2363 {
2364 return qe_invalid;
2365 }
2366
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.version_minor,f))
2367 {
2368 return qe_invalid;
2369 }
2370
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.version_patch,f))
2371 {
2372 return qe_invalid;
2373 }
2374
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2375 {
2376 return qe_invalid;
2377 }
2378
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2379 {
2380 return qe_invalid;
2381 }
2382
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.new_version_id_beta,f))
2383 {
2384 return qe_invalid;
2385 }
2386
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2387 {
2388 return qe_invalid;
2389 }
2390
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.new_version_id_release,f))
2391 {
2392 return qe_invalid;
2393 }
2394
2395 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2396
3/6
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
215 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2397 tempheader.version_minor = 55;
2398
2399
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2400 {
2401 return qe_invalid;
2402 }
2403
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&tempheader.new_version_id_date_month,f))
2404 {
2405 return qe_invalid;
2406 }
2407
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&tempheader.new_version_id_date_day,f))
2408 {
2409 return qe_invalid;
2410 }
2411
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2412 {
2413 return qe_invalid;
2414 }
2415
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2416 {
2417 return qe_invalid;
2418 }
2419
2420
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.new_version_devsig,256,f))
2421 {
2422 return qe_invalid;
2423 }
2424
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2425 strcpy(tempheader.new_version_devsig, "EmilyV99");
2426
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.new_version_compilername,256,f))
2427 {
2428 return qe_invalid;
2429 }
2430
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.new_version_compilerversion,256,f))
2431 {
2432 return qe_invalid;
2433 }
2434
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.product_name,1024,f))
2435 {
2436 return qe_invalid;
2437 }
2438
2439
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&tempheader.compilerid,f))
2440 {
2441 return qe_invalid;
2442 }
2443
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2444 {
2445 return qe_invalid;
2446 }
2447
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2448 {
2449 return qe_invalid;
2450 }
2451
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2452 {
2453 return qe_invalid;
2454 }
2455
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2456 {
2457 return qe_invalid;
2458 }
2459
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetw(&tempheader.developerid,f))
2460 {
2461 return qe_invalid;
2462 }
2463
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.made_in_module_name,1024,f))
2464 {
2465 return qe_invalid;
2466 }
2467
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.build_datestamp,256,f))
2468 {
2469 return qe_invalid;
2470 }
2471
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.build_timestamp,256,f))
2472 {
2473 return qe_invalid;
2474 }
2475 215 }
2476 else // <4
2477 {
2478 593 tempheader.version_major = 0;
2479 593 tempheader.version_minor = 0;
2480 593 tempheader.version_patch = 0;
2481 593 tempheader.new_version_id_fourth = 0;
2482 593 tempheader.new_version_id_alpha = 0;
2483 593 tempheader.new_version_id_beta = 0;
2484 593 tempheader.new_version_id_gamma = 0;
2485 593 tempheader.new_version_id_release = 0;
2486 593 tempheader.new_version_id_date_year = 0;
2487 593 tempheader.new_version_id_date_month = 0;
2488 593 tempheader.new_version_id_date_day = 0;
2489 593 tempheader.new_version_id_date_hour = 0;
2490 593 tempheader.new_version_id_date_minute = 0;
2491
2492 593 memset(tempheader.new_version_devsig, 0, 256);
2493 593 memset(tempheader.new_version_compilername, 0, 256);
2494 593 memset(tempheader.new_version_compilerversion, 0, 256);
2495 593 memset(tempheader.product_name, 0, 1024);
2496 593 strcpy(tempheader.product_name, "ZQuest Classic");
2497
2498 593 tempheader.compilerid = 0;
2499 593 tempheader.compilerversionnumber_first = 0;
2500 593 tempheader.compilerversionnumber_second = 0;
2501 593 tempheader.compilerversionnumber_third = 0;
2502 593 tempheader.compilerversionnumber_fourth = 0;
2503 593 tempheader.developerid = 0;
2504
2505 593 memset(tempheader.made_in_module_name, 0, 1024);
2506 593 memset(tempheader.build_datestamp, 0, 256);
2507 593 memset(tempheader.build_timestamp, 0, 256);
2508 }
2509
2510
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 593 times.
808 if ( version >= 5 )
2511 {
2512
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(tempheader.build_timezone,6,f))
2513 {
2514 return qe_invalid;
2515 }
2516 215 }
2517 else // < 5
2518 {
2519 593 memset(tempheader.build_timezone, 0, 6);
2520 }
2521
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 593 times.
808 if ( version >= 6 )
2522 {
2523 byte b;
2524
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&b,f))
2525 {
2526 return qe_invalid;
2527 }
2528 215 tempheader.external_zinfo = b?true:false;
2529 215 read_zinfo = true;
2530 215 }
2531
2532
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 593 times.
808 if(version >= 7)
2533 {
2534
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2535 {
2536 return qe_invalid;
2537 }
2538 215 }
2539 else
2540 {
2541 593 tempheader.new_version_is_nightly = false;
2542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 593 times.
593 if(tempheader.zelda_version < 0x255)
2543 {
2544
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 534 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
593 switch(tempheader.zelda_version)
2545 {
2546 case 0x254:
2547 tempheader.version_major = 2;
2548 tempheader.version_minor = 54;
2549 break;
2550 case 0x250:
2551
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 415 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 13 times.
534 switch(tempheader.build)
2552 {
2553 case 19:
2554 tempheader.version_major = 2;
2555 tempheader.version_minor = 50;
2556 tempheader.new_version_id_gamma = 1;
2557 break;
2558 case 20:
2559 tempheader.version_major = 2;
2560 tempheader.version_minor = 50;
2561 tempheader.new_version_id_gamma = 2;
2562 break;
2563 case 21:
2564 tempheader.version_major = 2;
2565 tempheader.version_minor = 50;
2566 tempheader.new_version_id_gamma = 3;
2567 break;
2568 case 22:
2569 tempheader.version_major = 2;
2570 tempheader.version_minor = 50;
2571 tempheader.new_version_id_gamma = 4;
2572 break;
2573 case 23:
2574 tempheader.version_major = 2;
2575 tempheader.version_minor = 50;
2576 tempheader.new_version_id_gamma = 5;
2577 break;
2578 case 24:
2579 31 tempheader.version_major = 2;
2580 31 tempheader.version_minor = 50;
2581 31 tempheader.new_version_id_release = -1;
2582 31 break;
2583 case 25:
2584 tempheader.version_major = 2;
2585 tempheader.version_minor = 50;
2586 tempheader.version_patch = 1;
2587 tempheader.new_version_id_gamma = 1;
2588 break;
2589 case 26:
2590 24 tempheader.version_major = 2;
2591 24 tempheader.version_minor = 50;
2592 24 tempheader.version_patch = 1;
2593 24 tempheader.new_version_id_gamma = 2;
2594 24 break;
2595 case 27:
2596 tempheader.version_major = 2;
2597 tempheader.version_minor = 50;
2598 tempheader.version_patch = 1;
2599 tempheader.new_version_id_gamma = 3;
2600 break;
2601 case 28:
2602 6 tempheader.version_major = 2;
2603 6 tempheader.version_minor = 50;
2604 6 tempheader.version_patch = 1;
2605 6 tempheader.new_version_id_release = -1;
2606 6 break;
2607 case 29:
2608 415 tempheader.version_major = 2;
2609 415 tempheader.version_minor = 50;
2610 415 tempheader.version_patch = 2;
2611 415 tempheader.new_version_id_release = -1;
2612 415 break;
2613 case 30:
2614 tempheader.version_major = 2;
2615 tempheader.version_minor = 50;
2616 tempheader.version_patch = 3;
2617 tempheader.new_version_id_gamma = 1;
2618 break;
2619 case 31:
2620 16 tempheader.version_major = 2;
2621 16 tempheader.version_minor = 53;
2622 16 tempheader.new_version_id_gamma = -1;
2623 16 break;
2624 case 32:
2625 29 tempheader.version_major = 2;
2626 29 tempheader.version_minor = 53;
2627 29 tempheader.new_version_id_release = -1;
2628 29 break;
2629 case 33:
2630 13 tempheader.version_major = 2;
2631 13 tempheader.version_minor = 53;
2632 13 tempheader.version_patch = 1;
2633 13 break;
2634 }
2635 534 break;
2636
2637 case 0x211:
2638 tempheader.version_major = 2;
2639 tempheader.version_minor = 11;
2640 tempheader.new_version_id_beta = tempheader.build;
2641 break;
2642 case 0x210:
2643 59 tempheader.version_major = 2;
2644 59 tempheader.version_minor = 10;
2645 59 tempheader.new_version_id_beta = tempheader.build;
2646 59 break;
2647 }
2648 593 }
2649 }
2650
2651
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 638 times.
808 if (version>=9)
2652 {
2653 170 std::string version_string;
2654
2/4
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
170 if(!p_getcstr(&version_string, f))
2655 {
2656 return qe_invalid;
2657 }
2658
2659 170 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2660 170 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 }
2662 else
2663 {
2664 638 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2665 }
2666 }
2667
2668
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 774 times.
832 if(printmetadata)
2669 {
2670
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2671 58 }
2672
2673 //{ Version Warning
2674
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 int32_t vercmp = tempheader.compareVer();
2675
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2676
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2677
4/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✓ Branch 3 taken 662 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 170 times.
1002 if(vercmp > 0 || (!vercmp &&
2678
2/4
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
170 (astatecmp > 0 || (!astatecmp &&
2679 170 avercmp > 0))))
2680 {
2681 bool r = true;
2682 if(loadquest_report)
2683 {
2684 enter_sys_pal();
2685 r = alert_confirm("Quest saved in newer version",
2686 "This quest was last saved in a newer version of ZQuest."
2687 " Attempting to load this quest may not work correctly; to"
2688 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2689 "\n\nWould you like to continue loading anyway? (Not recommended)");
2690 exit_sys_pal();
2691 }
2692 if(!r)
2693 return qe_silenterr;
2694 }
2695 //}
2696
2697 832 read_ext_zinfo = tempheader.external_zinfo;
2698
2699
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 *Header = tempheader;
2700 832 map_count=temp_map_count;
2701
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 vector<byte> vb{ temp_midi_flags, temp_midi_flags + 32 };
2702
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 midi_bitstr.inner() = vb;
2703
2704
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 unpack_qrs();
2705
2706 832 return 0;
2707 856 }
2708
2709 11589 int32_t readrules(PACKFILE *f, zquestheader *Header)
2710 {
2711
2/2
✓ Branch 0 taken 11566 times.
✓ Branch 1 taken 23 times.
11589 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11589 times.
11589 if (should_skip)
2713 return 0;
2714
2715 int32_t dummy;
2716 11589 zquestheader tempheader = *Header;
2717 11589 word s_version=0;
2718 11589 dword compatrule_version=0;
2719
2720
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 11115 times.
11589 if(tempheader.zelda_version >= 0x193)
2721 {
2722 //section version info
2723
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&s_version,f))
2724 {
2725 return qe_invalid;
2726 }
2727
2728
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (s_version > V_RULES)
2729 return qe_version;
2730
2731 474 FFCore.quest_format[vRules] = s_version;
2732
2733
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&dummy,f))
2734 {
2735 return qe_invalid;
2736 }
2737
2738
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 259 times.
474 if(s_version > 16)
2739 {
2740
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&compatrule_version,f))
2741 {
2742 return qe_invalid;
2743 }
2744 215 }
2745 474 FFCore.quest_format[vCompatRule] = compatrule_version;
2746
2747 //section size
2748
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&dummy,f))
2749 {
2750 return qe_invalid;
2751 }
2752
2753
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 215 times.
474 if ( s_version < 15 )
2754 {
2755 //finally... section data
2756
2/4
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
259 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2757 {
2758 return qe_invalid;
2759 }
2760 259 }
2761 else
2762 {
2763
2764
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2765 {
2766 return qe_invalid;
2767 }
2768
2769 }
2770 474 }
2771
2772 //{ bunch of compat stuff
2773 11589 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2774
2775
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 11092 times.
11589 unpack_qrs();
2776
2777
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<2)
2778 {
2779
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2780
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2781
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2782
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2783
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2784
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2785
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2786
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2787
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2788
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2789
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2790
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2791
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2792
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2793
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2794
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2795
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2796
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2797
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2798 82 }
2799
2800 //Now, do any updates...
2801
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
497 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2802 {
2803
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2804
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2805
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2806
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2807
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2808 82 }
2809
2810
3/4
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
497 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2811 {
2812
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2813 23 }
2814
2815
3/4
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
497 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2816 {
2817
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2818 23 }
2819
2820
3/4
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
497 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2821 {
2822
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2823 23 }
2824
2825
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(tempheader.zelda_version <= 0x210)
2826 {
2827
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2828 82 }
2829
2830
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 438 times.
497 if(tempheader.zelda_version == 0x210)
2831 {
2832
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2833
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2834
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2835 59 }
2836
2837
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(tempheader.zelda_version <= 0x210)
2838 {
2839
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2840
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2841 82 }
2842
2843 //might not be correct
2844
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 474 times.
497 if(tempheader.zelda_version < 0x210)
2845 {
2846
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2847
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2848
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2849 23 }
2850
2851
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(tempheader.zelda_version < 0x211)
2852 {
2853
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2854 82 }
2855
2856
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 492 times.
497 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2857 {
2858
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 475 times.
497 set_qr(qr_192b163_WARP,1);
2859 22 }
2860
2861
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 37 times.
22 if(tempheader.zelda_version == 0x210)
2862 {
2863
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2864
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2865
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2866 59 }
2867
2868
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
96 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2869 {
2870
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 237 times.
319 set_qr(qr_OLDPICKUP,1);
2871 82 }
2872
2873
3/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
497 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2874 {
2875
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2876
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2877 82 }
2878
2879
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2880 {
2881
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2882 82 }
2883
2884
4/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 297 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 169 times.
497 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2885 {
2886
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_PEAHATCLOCKVULN, 1);
2887 31 }
2888
2889
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
497 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2890 {
2891
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 set_qr(qr_OLD_DOORREPAIR, 1);
2892 82 }
2893
2894
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
297 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2895 {
2896
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 236 times.
318 set_qr(qr_OLD_SECRETMONEY, 1);
2897 82 }
2898
2899
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
297 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2900 {
2901
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 181 times.
318 set_qr(qr_OLD_POTION_OR_HC, 1);
2902 137 }
2903
2904
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
352 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2905 {
2906
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 126 times.
263 set_qr(qr_OFFSCREENWEAPONS, 1);
2907 137 }
2908
2909 //Bombchu fix.
2910
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 200 times.
352 if(tempheader.zelda_version == 0x250)
2911 {
2912
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 169 times.
200 if ( tempheader.build == 24 ) //2.50.0
2913 {
2914
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2915 31 }
2916
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 194 times.
200 if ( tempheader.build == 28 ) //2.50.1
2917 {
2918
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2919 6 }
2920
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 119 times.
200 if ( tempheader.build == 29 ) //2.50.2
2921 {
2922
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2923 81 }
2924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if ( tempheader.build == 30 ) //2.50.3RC1
2925 {
2926 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2927 }
2928 200 }
2929
2930
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
352 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2931 {
2932 // qr_OFFSETEWPNCOLLISIONFIX
2933 // All 'official' quests need this disabled.
2934 // All 2.10 and lower quests need this enabled to preseve compatability.
2935 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2936
2937 //~Gleeok
2938
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 120 times.
263 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2939
2940 // Broke in build 695
2941
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
143 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2942
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 set_qr(qr_BROKENSTATUES, 1);
2943 143 }
2944
11/14
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 479 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 595 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 595 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 578 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
358 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2945 {
2946
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2947 22 }
2948
8/8
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 228 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 13 times.
600 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2949 {
2950
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 318 times.
587 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2951 269 }
2952
2953
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2954 {
2955
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2956 82 }
2957
2958
4/6
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 215 times.
282 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2959 {
2960
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 163 times.
119 set_qr(qr_STEP_IS_FLOAT,0);
2961 282 }
2962
2963
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if ( tempheader.zelda_version < 0x250 )
2964 {
2965
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
2966 82 }
2967
2968
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version < 3)
2969 {
2970
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
2971
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
2972 82 }
2973
2974
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<4)
2975 {
2976
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
2977 82 }
2978
2979
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<5)
2980 {
2981
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2982 82 }
2983
2984
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<6)
2985 {
2986
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
2987 82 }
2988
2989
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<7) // January 2008
2990 {
2991
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
2992
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
2993 82 }
2994
2995
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<8)
2996 {
2997
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
2998 82 }
2999 else
3000 {
3001
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 set_bit(deprecated_rules, 12, 0);
3002 }
3003
3004
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<9) // October 2008
3005 {
3006
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
3007
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3008
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
3009
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3010 82 }
3011
3012
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<10) // December 2008
3013 {
3014
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
3015
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3016 82 }
3017
3018
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version<11) // April 2009
3019 {
3020
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3021 82 }
3022
3023 // This served no purpose.
3024 // if(s_version<12) // December 2009
3025 // {
3026 // set_qr(qr_BRKBLSHLDS_DEP,0);
3027 // set_qr(qr_OLDTRIBBLES_DEP,0);
3028 // }
3029
3030 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3031
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(s_version < 13)
3032 {
3033
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
3034 82 }
3035
3036 // Not entirely sure this is the best place for this...
3037 //2.50.2 bitmap offset fix
3038 497 memset(extra_rules, 0, EXTRARULES_SIZE);
3039
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
497 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3040 {
3041
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 139 times.
282 set_er(er_BITMAPOFFSET, 1);
3042
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 set_qr(qr_BITMAPOFFSETFIX, 1);
3043 143 }
3044 //required because quest templates also used this bit, although
3045 //it never did anything, before. -Z
3046
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 158 times.
358 if ( tempheader.zelda_version == 0x250 )
3047 {
3048
5/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 103 times.
200 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3049 {
3050
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_er(er_BITMAPOFFSET, 0);
3051
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_qr(qr_BITMAPOFFSETFIX, 0);
3052 97 }
3053 200 }
3054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358 times.
358 if ( tempheader.zelda_version == 0x254 )
3055 {
3056 set_er(er_BITMAPOFFSET, 0);
3057 set_qr(qr_BITMAPOFFSETFIX, 0);
3058 }
3059
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 143 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
358 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3060 {
3061 set_er(er_BITMAPOFFSET, 0);
3062 set_qr(qr_BITMAPOFFSETFIX, 0);
3063 }
3064 //optimise fast drawing for older versions.
3065
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
358 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3066 {
3067
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 120 times.
358 set_qr(qr_OLDSPRITEDRAWS, 1);
3068 282 }
3069 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3070 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3071 //older quests can set the rule by hand. We need a new qst.dat again.
3072
4/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 215 times.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3073 {
3074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 430 times.
430 set_qr(qr_OLDEWPNPARENT, 1);
3075 }
3076
4/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 215 times.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3077 {
3078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 430 times.
430 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3079 }
3080
4/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 215 times.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3081 {
3082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 430 times.
430 set_qr(qr_OLDQUESTMISC, 1);
3083 }
3084
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3085 {
3086
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3087
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDEWPNPARENT, 0);
3088
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDQUESTMISC, 0);
3089 282 }
3090
3091 //item scripts continue to run
3092
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3093 {
3094
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3095
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3096
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3097
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3098
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3099
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3100
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3101 282 }
3102
3103
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3104 {
3105
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3106 282 }
3107
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3108 {
3109
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_TRACESCRIPTIDS, 0);
3110
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3111
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3112
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_250DIVISION,1);
3113
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3114
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3115
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_FORCE_INLINE,0);
3116
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BINARY_32BIT,0);
3117
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 274 times.
282 if ( get_qr(qr_SELECTAWPN) )
3118 {
3119
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3120 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3121 //Now they **do**, unless you disable that behaviour.
3122 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3123 //now enable the disable L/R item swap on load.
3124 8 }
3125
3126 282 }
3127
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3128 {
3129 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3130
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3131 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3132 //animations ending earlier than they should.
3133
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3134 //Enemies would ignore solidity on the top half of combos
3135
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3136 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3137
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3138 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3139
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3140 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3141
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3142 282 }
3143
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x255 )
3144 {
3145
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOFFCWAITDRAW, 1);
3146
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOITEMWAITDRAW, 1);
3147
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3148
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3149 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3150 282 }
3151
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3152 {
3153
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3154 282 }
3155
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3156 {
3157
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_OLD_PRINTF_ARGS, 1);
3158 282 }
3159
3160
3161
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3162 {
3163
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_BROKEN_RING_POWER, 1);
3164 282 }
3165
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3166 {
3167
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3168 282 }
3169
5/6
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 163 times.
✓ Branch 5 taken 52 times.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3170 {
3171
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3172 282 }
3173
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
334 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3174 {
3175 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
334 if(get_qr(qr_SET_XBUTTON_ITEMS))
3177 set_qr(qr_SET_YBUTTON_ITEMS,1);
3178 282 }
3179
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3180 {
3181
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3182 282 }
3183
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3184 {
3185
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_OLD_CHEST_COLLISION,1);
3186 282 }
3187
3188
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3189 {
3190
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3191 282 }
3192 //Sideview spikes in 2.50.0
3193
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
282 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3194 {
3195
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 196 times.
333 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3196 137 }
3197 //more 2.50 fixes -Z
3198
4/4
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 215 times.
352 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3199 {
3200
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 69 times.
263 set_qr(qr_MELEEMAGICCOST, 0);
3201
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3202
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_OLDMIRRORCOMBOS, 1);
3203
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENBOOKCOST, 1);
3204
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENCHARINTDRAWING, 1);
3205
3206 224 }
3207
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 439 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
439 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3208 {
3209 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3210 set_qr(qr_MELEEMAGICCOST, 1);
3211 }
3212
3213
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 416 times.
439 if(tempheader.zelda_version < 0x193)
3214 {
3215
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3216 23 }
3217
3218
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 157 times.
439 if(tempheader.zelda_version < 0x255)
3219 {
3220
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDINFMAGIC, 1);
3221 282 }
3222
3223
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 357 times.
439 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3224 {
3225
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3226 82 }
3227
3228
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
439 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3229 {
3230
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 157 times.
439 set_qr(qr_OLD_F6,1);
3231 282 }
3232
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3233 {
3234
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3235 282 }
3236
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3237 {
3238
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3239 282 }
3240
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3241 {
3242
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 52 times.
334 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3243 282 }
3244 //}
3245
3246
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3247
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3248
3249
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 2) //Old CSet2 Handling
3250
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCS2,1);
3251
3252
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3253
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3254
3255
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3256
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3257
3258
3/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 82 times.
282 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3259
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3260
3261
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3262
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3263
3264
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3265
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3266
3267
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3268
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3269
3270
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 9)
3271 {
3272 //Hardcoded BS Patras
3273
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_BS_PATRA,1);
3274 //Hardcoded Patra Inner Eye offsets
3275
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3276 //Broken 'Big enemy' animation style
3277
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3278 //Broken Attribute 31/32
3279
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3280 282 }
3281
3282
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 10) //Shared candle use limits
3283
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3284
3285
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 11) //No cross-screen return points
3286
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_RESPAWN_POINTS,1);
3287
3288
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 12)
3289 {
3290 //Old fire trail duration
3291
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3292 //Old Intro String in Ganon Room Behavior
3293
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3294
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_GANONINTRO,1);
3295 282 }
3296
3297
2/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
282 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3298 set_qr(qr_ANONE_NOANIM,1);
3299
3300
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 14) //Old Bridge Combo Behavior
3301
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3302
3303
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 15) //Broken Z3 Animation
3304
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3305
3306
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3307
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3308
3309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 17)
3310 {
3311 //Old Quake/DrawYOffset behavior
3312 //set_qr(qr_OLD_DRAWOFFSET,1);
3313 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3314 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3315 282 }
3316
3317
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 18)
3318 {
3319 //Broken DrawScreen Derivative Functions
3320
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3321 //Scrolling Cancels Charge
3322
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3323 282 }
3324
3325
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3326
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3327
3328
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 20)
3329
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3330
3331
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 21)
3332 {
3333
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3334
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3335
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3336
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BUG_NET,1);
3337
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3338 282 }
3339
3340
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 22)
3341
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3342
3343
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 23)
3344
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_HALF_MAGIC,1);
3345
3346
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 24)
3347 {
3348
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3349
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3350 282 }
3351
3352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 25)
3353 {
3354
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3355
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3356
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3357 282 }
3358
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 26)
3359 {
3360
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3361
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_POLVIRE_NO_SHADOW,1);
3362
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3363 282 }
3364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3365 {
3366
2/2
✓ Branch 0 taken 84882 times.
✓ Branch 1 taken 282 times.
85164 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3367
1/2
✓ Branch 0 taken 84882 times.
✗ Branch 1 not taken.
84882 set_qr(q,0);
3368
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 282 times.
1974 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3369
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 set_qr(q,0);
3370 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3371 282 }
3372
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
282 if(compatrule_version < 28)
3373
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3374
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 29)
3375
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3376
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 30)
3377 {
3378
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DECO_2_YOFFSET,1);
3379
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCREENSTATE_80s_BUG,1);
3380 287 }
3381
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 31)
3382 {
3383
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3384
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3385 287 }
3386
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 32)
3387
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3388
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 33)
3389
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NO_LIFT_SPRITE,1);
3390
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 34)
3391 {
3392
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3393
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3394
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3395
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3396 287 }
3397
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 35)
3398 {
3399
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3400
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3401 289 }
3402
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 5 times.
294 if(compatrule_version < 36)
3403
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_OLD_SHALLOW_SFX,1);
3404
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
294 if(compatrule_version < 37)
3405
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3406
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 38)
3407
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3408
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 39)
3409
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3410
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 40)
3411
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3412
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 41)
3413
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKENHITBY,1);
3414
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 42)
3415
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3416
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 43)
3417
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_OLD_BOMB_HITBOXES,1);
3418
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 44)
3419
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3420
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 45)
3421
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3422
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 46)
3423
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3424
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 47)
3425 {
3426
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3427
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3428 299 }
3429
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 48)
3430
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GUY_HANDLING,1);
3431
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 49)
3432
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3433
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 50)
3434
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3435
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 51)
3436
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3437
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if (compatrule_version < 52)
3438
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3439
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 53)
3440 {
3441
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SUBSCR,1);
3442
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3443
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3444 299 }
3445
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 54)
3446
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3447
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 55)
3448
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3449
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 56)
3450
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3451
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 57)
3452
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3453
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 58)
3454
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3455
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 59)
3456
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3457
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 60)
3458
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3459
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 61)
3460
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3461
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 62)
3462
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3463
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 4 times.
304 if(compatrule_version < 63)
3464 {
3465
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_LIFTSWIM,1);
3466
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3467 300 }
3468
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 4 times.
304 if(compatrule_version < 64)
3469
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3470
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 21 times.
304 if(compatrule_version < 65)
3471
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3472
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if(compatrule_version < 66)
3473
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3474
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if(compatrule_version < 67)
3475
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3476
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if(compatrule_version < 68)
3477
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3478
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if(compatrule_version < 69)
3479
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3480
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if (compatrule_version < 70)
3481
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_BROKEN_CONVEYORS, 1);
3482
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if (compatrule_version < 71)
3483
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3484
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if (compatrule_version < 72)
3485
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3486
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
346 if (compatrule_version < 73)
3487 {
3488
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_OLD_LANDING_SFX, 1);
3489
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3490 328 }
3491
5/6
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
346 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3492
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 327 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3493
5/6
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
673 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3494
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 327 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3495
5/6
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 672 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
1000 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3496
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 327 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3497
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 999 times.
1327 if (compatrule_version < 77)
3498
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3499
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 999 times.
1327 if (compatrule_version < 78)
3500
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3501
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 999 times.
1327 if (compatrule_version < 79)
3502
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_BROKEN_SYSTEM_COLORS, 1);
3503
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 999 times.
1327 if (compatrule_version < 80)
3504
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 set_qr(qr_ZS_OLD_SUSPEND_FFC, 1);
3505
5/6
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 993 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
1327 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3506
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 327 times.
7 set_qr(qr_BROKEN_SCROLL_INSTEAD_OF_DROWN_FALL, 1);
3507
5/6
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 1320 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
1654 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 6) < 0))
3508
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 327 times.
7 set_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE, 1);
3509
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 1647 times.
1981 if (compatrule_version < 82)
3510 {
3511
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 set_qr(qr_EW_ROCKS_HARDCODED_BREAK_ON_SOLID, 1);
3512
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 set_qr(qr_IMPRECISE_WEAPON_SOLIDITY_CHECKS, 1);
3513 334 }
3514
5/6
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 1647 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
1981 if (compatrule_version < 83 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3515
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 327 times.
7 set_qr(qr_BROKEN_BLOCKHOLE_PITFALLS, 1);
3516
5/6
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 1974 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
2308 if (compatrule_version < 84 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3517
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 327 times.
7 set_qr(qr_CUSTOM_WEAPON_BROKEN_SIZE, 1);
3518
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 2301 times.
2635 if (compatrule_version < 85)
3519
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 set_qr(qr_OLD_WEAPON_REFLECTION, 1);
3520
5/6
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2291 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 17 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
2635 if (compatrule_version < 86 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3521
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 327 times.
17 set_qr(qr_OLD_SPRITE_FALL_DROWN, 1);
3522
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2618 times.
2962 if (compatrule_version < 87)
3523
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_TERMINAL_VELOCITY, 1);
3524
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2618 times.
2962 if (compatrule_version < 88)
3525
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_SCRIPT_LEVEL_GLOBAL_STATES, 1);
3526
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2618 times.
2962 if (compatrule_version < 89)
3527
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_BROKEN_ARMOS_GRAVE_BIGHITBOX_COLLISION, 1);
3528
3529
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2618 times.
2962 if (compatrule_version < 90)
3530 {
3531
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_CLASSIC_DRAWING_ORDER, 1);
3532
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_WEAPON_DRAW_ANIMATE_TIMING, 1);
3533 344 }
3534
3535
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 2616 times.
2962 if (compatrule_version < 91)
3536 {
3537
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 set_qr(qr_OLD_SCRIPTS_INTERNAL_ARRAYS_BOUND_INDEX, 1);
3538
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 set_qr(qr_OLD_SCRIPTS_ARRAYS_NON_ZERO_DEFAULT_VALUE, 1);
3539 346 }
3540
3541
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 2616 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 19 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
2962 if (compatrule_version < 92 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3542
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 327 times.
19 set_qr(qr_OLD_PIT_SENSITIVITY, 1);
3543
3544
5/6
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 2925 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
3289 if (compatrule_version < 93 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 12) < 0))
3545
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 327 times.
37 set_qr(qr_ACTIVE_SHIELD_PASSIVE_ROC_NO_SCRIPT, 1);
3546
3547
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 94)
3548
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_OLD_SCRIPTS_MESSAGE_DATA_BINARY_ENCODING, 1);
3549
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 95)
3550
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_ONLY_MARK_SCREENS_VISITED_IF_MAP_VIEWABLE, 1);
3551
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 96)
3552
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_ACTIVE_SUB_IGNORE_8PX, 1);
3553
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 97)
3554 {
3555
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_DRAWCOMBO_IGNORES_FRAME, 1);
3556
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_DRAWTILE_TALL_DRAWS_WRAP_POORLY, 1);
3557 364 }
3558
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 98)
3559
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_BUGGY_MULTIPLE_WIND, 1);
3560
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 3252 times.
3616 if (compatrule_version < 99)
3561
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 set_qr(qr_NO_DEATH_EVENTS_FOR_SEGMENTED_ENEMY_CORES, 1);
3562
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 3251 times.
3616 if (compatrule_version < 100)
3563
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 set_qr(qr_BROKEN_COPYCAT_SELF_TRIGGER, 1);
3564
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 3251 times.
3616 if (compatrule_version < 101)
3565
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 set_qr(qr_BROKEN_WATER_PASSIVE_DAMAGE, 1);
3566
3567
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 3119 times.
3616 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3568
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 215 times.
497 if (s_version < 16)
3569
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3570
3571
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 *Header = tempheader;
3572
3573 497 return 0;
3574 22681 }
3575
3576 4224112 void init_msgstr(MsgStr *str)
3577 {
3578
2/4
✓ Branch 0 taken 4224112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4224112 times.
4224112 str->setFromLegacyEncoding("");
3579 4224112 str->nextstring=0;
3580 4224112 str->tile=0;
3581 4224112 str->cset=0;
3582 4224112 str->trans=false;
3583 4224112 str->font=font_zfont;
3584 4224112 str->y=32;
3585 4224112 str->sfx=18;
3586 4224112 str->listpos=0;
3587 4224112 str->x=24;
3588 4224112 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3589 4224112 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3590 4224112 str->hspace=0;
3591 4224112 str->vspace=0;
3592 4224112 str->stringflags=0;
3593 4224112 str->margins[up] = 8;
3594 4224112 str->margins[down] = 0;
3595 4224112 str->margins[left] = 8;
3596 4224112 str->margins[right] = 8;
3597 4224112 str->portrait_tile = 0;
3598 4224112 str->portrait_cset = 0;
3599 4224112 str->portrait_x = 0;
3600 4224112 str->portrait_y = 0;
3601 4224112 str->portrait_tw = 1;
3602 4224112 str->portrait_th = 1;
3603 4224112 str->shadow_type = 0;
3604 4224112 str->shadow_color = 0;
3605 4224112 str->drawlayer = 6;
3606 4224112 }
3607
3608 497 void init_msgstrings(int32_t start, int32_t end)
3609 {
3610
2/4
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 497 times.
497 if(end <= start || end-start > msg_strings_size)
3611 return;
3612
3613
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 4071424 times.
4071921 for(int32_t i=start; i<end; i++)
3614 {
3615 4071424 init_msgstr(&MsgStrings[i]);
3616 4071424 MsgStrings[i].listpos=i;
3617 4071424 }
3618
3619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if(start==0)
3620 {
3621
2/4
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 497 times.
497 MsgStrings[0].setFromLegacyEncoding("(None)");
3622 497 MsgStrings[0].listpos = 0;
3623 497 }
3624 497 }
3625
3626 498 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3627 {
3628
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3629
3630 498 MsgStr tempMsgString;
3631
1/2
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
498 init_msgstr(&tempMsgString);
3632
3633 498 word temp_msg_count=0;
3634 word temp_expansion[16];
3635 498 memset(temp_expansion, 0, 16*sizeof(word));
3636 498 char buf[8193] = {0};
3637
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 474 times.
498 if(Header->zelda_version < 0x193)
3638 {
3639 byte tempbyte;
3640 24 int32_t strings_to_read=0;
3641
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3642
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3643
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3644
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3645 {
3646 18 strings_to_read=128;
3647 18 temp_msg_count=Header->old_str_count;
3648
3649 // Some sort of string count corruption seems to be common in old quests
3650
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3651 {
3652 temp_msg_count=128;
3653 }
3654 18 }
3655
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3656 {
3657 strings_to_read=255;
3658 temp_msg_count=Header->old_str_count;
3659 }
3660 else
3661 {
3662
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3663 {
3664 return qe_invalid;
3665 }
3666
3667 6 strings_to_read=temp_msg_count;
3668
3669
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3670 {
3671 Z_message("Reallocating string buffer...\n");
3672
3673 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3674 // return qe_nomem;
3675
3676 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3677 delete[] MsgStrings;
3678 MsgStrings = new MsgStr[MAXMSGS];
3679 msg_strings_size = MAXMSGS;
3680 for(auto q = 0; q < msg_strings_size; ++q)
3681 {
3682 MsgStrings[q].clear();
3683 }
3684 }
3685 }
3686
3687 //reset the message strings
3688
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3689
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3690
3691
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3692 {
3693
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3694 2550 tempMsgString.listpos = x;
3695
3696
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3697 {
3698 return qe_invalid;
3699 }
3700
3701 2550 buf[74] = '\0';
3702
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3703
3704
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3705 {
3706 return qe_invalid;
3707 }
3708
3709
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3710
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3711 {
3712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3713
3714
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3715 {
3716 return qe_invalid;
3717 }
3718
3719
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3720 {
3721 return qe_invalid;
3722 }
3723 2304 }
3724 else
3725 {
3726
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3727 {
3728 return qe_invalid;
3729 }
3730
3731
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3732 {
3733 return qe_invalid;
3734 }
3735 }
3736
3737
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3738 {
3739
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3740 2549 }
3741 2550 }
3742 24 }
3743 else
3744 {
3745 int32_t dummy_int;
3746 word s_version;
3747
3748 //section version info
3749
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&s_version,f))
3750 {
3751 return qe_invalid;
3752 }
3753
3754
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (s_version > V_STRINGS)
3755 return qe_version;
3756
3757 474 FFCore.quest_format[vStrings] = s_version;
3758
3759
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!read_deprecated_section_cversion(f))
3760 {
3761 return qe_invalid;
3762 }
3763
3764 //section size
3765
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&dummy_int,f))
3766 {
3767 return qe_invalid;
3768 }
3769
3770 //finally... section data
3771
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&temp_msg_count,f))
3772 {
3773 return qe_invalid;
3774 }
3775
3776
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
474 if(temp_msg_count >= msg_strings_size && !should_skip)
3777 {
3778 Z_message("Reallocating string buffer...\n");
3779
3780 delete[] MsgStrings;
3781 MsgStrings = new MsgStr[MAXMSGS];
3782 msg_strings_size = MAXMSGS;
3783 for(auto q = 0; q < msg_strings_size; ++q)
3784 {
3785 MsgStrings[q].clear();
3786 }
3787 }
3788
3789 //reset the message strings
3790
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 215 times.
474 if(s_version < 7)
3791
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3792
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (!should_skip)
3793
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 init_msgstrings(0,msg_strings_size);
3794
3795 474 int32_t string_length=(s_version<2)?73:145;
3796
3797
2/2
✓ Branch 0 taken 149640 times.
✓ Branch 1 taken 474 times.
150114 for(int32_t i=0; i<temp_msg_count; i++)
3798 {
3799
1/2
✓ Branch 0 taken 149640 times.
✗ Branch 1 not taken.
149640 init_msgstr(&tempMsgString);
3800
2/2
✓ Branch 0 taken 148502 times.
✓ Branch 1 taken 1138 times.
149640 if (s_version >= 11)
3801 1138 tempMsgString.encoding_type = MsgStr::EncodingType::Ascii;
3802 149640 tempMsgString.listpos = i;
3803
2/2
✓ Branch 0 taken 17714 times.
✓ Branch 1 taken 131926 times.
149640 if(s_version > 8)
3804 {
3805
2/4
✓ Branch 0 taken 17714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17714 times.
✗ Branch 3 not taken.
17714 if(!p_igetl(&string_length,f))
3806 {
3807 return qe_invalid;
3808 }
3809 17714 }
3810
3811
2/4
✓ Branch 0 taken 149640 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 149640 times.
149640 if (string_length < 0 || string_length > 8193)
3812 {
3813 return qe_invalid;
3814 }
3815
3816
2/2
✓ Branch 0 taken 144761 times.
✓ Branch 1 taken 4879 times.
149640 if (string_length > 0)
3817 {
3818
2/4
✓ Branch 0 taken 144761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144761 times.
✗ Branch 3 not taken.
144761 if (!pfread(buf, string_length, f))
3819 {
3820 return qe_invalid;
3821 }
3822 144761 }
3823 else
3824 {
3825 4879 buf[0] = 0;
3826 }
3827
3828
2/4
✓ Branch 0 taken 149640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149640 times.
✗ Branch 3 not taken.
149640 if(!p_igetw(&tempMsgString.nextstring,f))
3829 {
3830 return qe_invalid;
3831 }
3832
3833
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 116027 times.
149640 if(s_version<2)
3834 {
3835 33613 buf[72] = '\0';
3836
2/4
✓ Branch 0 taken 33613 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33613 times.
✗ Branch 3 not taken.
33613 tempMsgString.setFromLegacyEncoding(buf);
3837 33613 }
3838 else
3839 {
3840 // June 2008: A bug corrupted the last 4 chars of a string.
3841 // Discard these.
3842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116027 times.
116027 if (!should_skip)
3843 {
3844
1/2
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
116027 if(s_version<3)
3845 {
3846 for(int32_t j=140; j<144; j++)
3847 {
3848 buf[j] = '\0';
3849 }
3850 }
3851
1/2
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
116027 if(string_length > 8192) string_length = 8192;
3852 116027 buf[string_length]='\0'; //Force-terminate
3853
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 tempMsgString.set(buf, tempMsgString.encoding_type);
3854 116027 }
3855
3856
2/2
✓ Branch 0 taken 17714 times.
✓ Branch 1 taken 98313 times.
116027 if ( s_version >= 6 )
3857 {
3858
2/4
✓ Branch 0 taken 17714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17714 times.
✗ Branch 3 not taken.
17714 if(!p_igetl(&tempMsgString.tile,f))
3859 {
3860 return qe_invalid;
3861 }
3862 17714 }
3863 else
3864 {
3865
2/4
✓ Branch 0 taken 98313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98313 times.
✗ Branch 3 not taken.
98313 if(!p_igetw(&tempMsgString.tile,f))
3866 {
3867 return qe_invalid;
3868 }
3869 }
3870
3871
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_getc(&tempMsgString.cset,f))
3872 {
3873 return qe_invalid;
3874 }
3875
3876 byte dummy_char;
3877
3878
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3879 {
3880 return qe_invalid;
3881 }
3882
3883 116027 tempMsgString.trans=dummy_char!=0;
3884
3885
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_getc(&tempMsgString.font,f))
3886 {
3887 return qe_invalid;
3888 }
3889
3890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116027 times.
116027 if(s_version < 5)
3891 {
3892 if(!p_getc(&tempMsgString.y,f))
3893 {
3894 return qe_invalid;
3895 }
3896 }
3897 else
3898 {
3899
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_igetw(&tempMsgString.x,f))
3900 {
3901 return qe_invalid;
3902 }
3903
3904
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_igetw(&tempMsgString.y,f))
3905 {
3906 return qe_invalid;
3907 }
3908
3909
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_igetw(&tempMsgString.w,f))
3910 {
3911 return qe_invalid;
3912 }
3913
3914
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_igetw(&tempMsgString.h,f))
3915 {
3916 return qe_invalid;
3917 }
3918
3919
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_getc(&tempMsgString.hspace,f))
3920 {
3921 return qe_invalid;
3922 }
3923
3924
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_getc(&tempMsgString.vspace,f))
3925 {
3926 return qe_invalid;
3927 }
3928
3929
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_getc(&tempMsgString.stringflags,f))
3930 {
3931 return qe_invalid;
3932 }
3933 }
3934
3935
2/2
✓ Branch 0 taken 98313 times.
✓ Branch 1 taken 17714 times.
116027 if(s_version >= 7)
3936 {
3937
2/2
✓ Branch 0 taken 17714 times.
✓ Branch 1 taken 70856 times.
88570 for(int32_t q = 0; q < 4; ++q)
3938 {
3939
2/4
✓ Branch 0 taken 70856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70856 times.
✗ Branch 3 not taken.
70856 if(!p_getc(&tempMsgString.margins[q],f))
3940 {
3941 return qe_invalid;
3942 }
3943 70856 }
3944
3945
2/4
✓ Branch 0 taken 17714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17714 times.
✗ Branch 3 not taken.
17714 if(!p_igetl(&tempMsgString.portrait_tile,f))
3946 {
3947 return qe_invalid;
3948 }
3949
3950
2/4
✓ Branch 0 taken 17714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17714 times.
✗ Branch 3 not taken.
17714 if(!p_getc(&tempMsgString.portrait_cset,f))
3951 {
3952 return qe_invalid;
3953 }
3954
3955
2/4
✓ Branch 0 taken 17714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17714 times.
✗ Branch 3 not taken.
17714 if(!p_getc(&tempMsgString.portrait_x,f))
3956 {
3957 return qe_invalid;
3958 }
3959
3960
2/4
✓ Branch 0 taken 17714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17714 times.
✗ Branch 3 not taken.
17714 if(!p_getc(&tempMsgString.portrait_y,f))
3961 {
3962 return qe_invalid;
3963 }
3964
3965
2/4
✓ Branch 0 taken 17714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17714 times.
✗ Branch 3 not taken.
17714 if(!p_getc(&tempMsgString.portrait_tw,f))
3966 {
3967 return qe_invalid;
3968 }
3969
3970
2/4
✓ Branch 0 taken 17714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17714 times.
✗ Branch 3 not taken.
17714 if(!p_getc(&tempMsgString.portrait_th,f))
3971 {
3972 return qe_invalid;
3973 }
3974 17714 }
3975
3976
2/2
✓ Branch 0 taken 17714 times.
✓ Branch 1 taken 98313 times.
116027 if(s_version >= 8)
3977 {
3978
2/4
✓ Branch 0 taken 17714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17714 times.
✗ Branch 3 not taken.
17714 if(!p_getc(&tempMsgString.shadow_type,f))
3979 {
3980 return qe_invalid;
3981 }
3982
3983
2/4
✓ Branch 0 taken 17714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17714 times.
✗ Branch 3 not taken.
17714 if(!p_getc(&tempMsgString.shadow_color,f))
3984 {
3985 return qe_invalid;
3986 }
3987 17714 }
3988
3989
2/2
✓ Branch 0 taken 17405 times.
✓ Branch 1 taken 98622 times.
116027 if(s_version >= 10)
3990 {
3991
2/4
✓ Branch 0 taken 17405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17405 times.
✗ Branch 3 not taken.
17405 if(!p_getc(&tempMsgString.drawlayer,f))
3992 {
3993 return qe_invalid;
3994 }
3995 17405 }
3996
3997
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_getc(&tempMsgString.sfx,f))
3998 {
3999 return qe_invalid;
4000 }
4001
4002
1/2
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
116027 if(s_version>3)
4003 {
4004
2/4
✓ Branch 0 taken 116027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116027 times.
✗ Branch 3 not taken.
116027 if(!p_igetw(&tempMsgString.listpos,f))
4005 {
4006 return qe_invalid;
4007 }
4008 116027 }
4009 }
4010
4011
1/2
✓ Branch 0 taken 149640 times.
✗ Branch 1 not taken.
149640 if (!should_skip)
4012 {
4013
1/2
✓ Branch 0 taken 149640 times.
✗ Branch 1 not taken.
149640 MsgStrings[i].copyAll(tempMsgString);
4014 149640 }
4015 149640 }
4016 }
4017
4018
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 497 times.
498 if (!should_skip)
4019 497 msg_count=temp_msg_count;
4020
4021 498 return 0;
4022 498 }
4023
4024 498 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4025 {
4026
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4027
4028
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
504 if((Header->zelda_version < 0x192)||
4029
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 474 times.
480 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4030 {
4031 18 return 0;
4032 }
4033
4034 480 word temp_door_combo_set_count=0;
4035 DoorComboSet tempDoorComboSet;
4036 word dummy_word;
4037 int32_t dummy_long;
4038 byte padding;
4039 480 int32_t s_version = 0;
4040
4041
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 479 times.
480 if (!should_skip)
4042 {
4043 479 DoorComboSets = {};
4044 479 DoorComboSetNames = {};
4045 479 }
4046
4047
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 474 times.
480 if(Header->zelda_version > 0x192)
4048 {
4049 //section version info
4050
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&s_version,f))
4051 {
4052 return qe_invalid;
4053 }
4054
4055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (s_version > V_DOORS)
4056 return qe_version;
4057
4058 474 FFCore.quest_format[vDoors] = s_version;
4059
4060
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&dummy_word,f))
4061 {
4062 return qe_invalid;
4063 }
4064
4065 //section size
4066
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy_long,f))
4067 {
4068 return qe_invalid;
4069 }
4070 474 }
4071
4072 //finally... section data
4073
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_igetw(&temp_door_combo_set_count,f))
4074 {
4075 return qe_invalid;
4076 }
4077
4078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4079 {
4080 return qe_invalid;
4081 }
4082
4083
2/2
✓ Branch 0 taken 5720 times.
✓ Branch 1 taken 480 times.
6200 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4084 {
4085 5720 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4086
4087 //name
4088 char name[21];
4089
1/2
✓ Branch 0 taken 5720 times.
✗ Branch 1 not taken.
5720 if(!pfread(&name,sizeof(name),f))
4090 {
4091 return qe_invalid;
4092 }
4093
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5706 times.
5720 if (!should_skip)
4094 5706 DoorComboSetNames[i] = name;
4095
4096
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 40 times.
5720 if(Header->zelda_version < 0x193)
4097 {
4098
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4099 {
4100 return qe_invalid;
4101 }
4102 40 }
4103
4104 //up door
4105
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4106 {
4107
2/2
✓ Branch 0 taken 205920 times.
✓ Branch 1 taken 51480 times.
257400 for(int32_t k=0; k<4; k++)
4108 {
4109
1/2
✓ Branch 0 taken 205920 times.
✗ Branch 1 not taken.
205920 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4110 {
4111 return qe_invalid;
4112 }
4113 205920 }
4114 51480 }
4115
4116
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4117 {
4118
2/2
✓ Branch 0 taken 205920 times.
✓ Branch 1 taken 51480 times.
257400 for(int32_t k=0; k<4; k++)
4119 {
4120
1/2
✓ Branch 0 taken 205920 times.
✗ Branch 1 not taken.
205920 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4121 {
4122 return qe_invalid;
4123 }
4124 205920 }
4125 51480 }
4126
4127 //down door
4128
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4129 {
4130
2/2
✓ Branch 0 taken 205920 times.
✓ Branch 1 taken 51480 times.
257400 for(int32_t k=0; k<4; k++)
4131 {
4132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205920 times.
205920 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4133 {
4134 return qe_invalid;
4135 }
4136 205920 }
4137 51480 }
4138
4139
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4140 {
4141
2/2
✓ Branch 0 taken 205920 times.
✓ Branch 1 taken 51480 times.
257400 for(int32_t k=0; k<4; k++)
4142 {
4143
1/2
✓ Branch 0 taken 205920 times.
✗ Branch 1 not taken.
205920 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4144 {
4145 return qe_invalid;
4146 }
4147 205920 }
4148 51480 }
4149
4150 //left door
4151
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4152 {
4153
2/2
✓ Branch 0 taken 308880 times.
✓ Branch 1 taken 51480 times.
360360 for(int32_t k=0; k<6; k++)
4154 {
4155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308880 times.
308880 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4156 {
4157 return qe_invalid;
4158 }
4159 308880 }
4160 51480 }
4161
4162
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4163 {
4164
2/2
✓ Branch 0 taken 308880 times.
✓ Branch 1 taken 51480 times.
360360 for(int32_t k=0; k<6; k++)
4165 {
4166
1/2
✓ Branch 0 taken 308880 times.
✗ Branch 1 not taken.
308880 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4167 {
4168 return qe_invalid;
4169 }
4170 308880 }
4171 51480 }
4172
4173 //right door
4174
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4175 {
4176
2/2
✓ Branch 0 taken 308880 times.
✓ Branch 1 taken 51480 times.
360360 for(int32_t k=0; k<6; k++)
4177 {
4178
1/2
✓ Branch 0 taken 308880 times.
✗ Branch 1 not taken.
308880 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4179 {
4180 return qe_invalid;
4181 }
4182 308880 }
4183 51480 }
4184
4185
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 5720 times.
57200 for(int32_t j=0; j<9; j++)
4186 {
4187
2/2
✓ Branch 0 taken 308880 times.
✓ Branch 1 taken 51480 times.
360360 for(int32_t k=0; k<6; k++)
4188 {
4189
1/2
✓ Branch 0 taken 308880 times.
✗ Branch 1 not taken.
308880 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4190 {
4191 return qe_invalid;
4192 }
4193 308880 }
4194 51480 }
4195
4196 //up bomb rubble
4197
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 5720 times.
17160 for(int32_t j=0; j<2; j++)
4198 {
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4200 {
4201 return qe_invalid;
4202 }
4203 11440 }
4204
4205
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 5720 times.
17160 for(int32_t j=0; j<2; j++)
4206 {
4207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4208 {
4209 return qe_invalid;
4210 }
4211 11440 }
4212
4213 //down bomb rubble
4214
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 5720 times.
17160 for(int32_t j=0; j<2; j++)
4215 {
4216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4217 {
4218 return qe_invalid;
4219 }
4220 11440 }
4221
4222
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 5720 times.
17160 for(int32_t j=0; j<2; j++)
4223 {
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4225 {
4226 return qe_invalid;
4227 }
4228 11440 }
4229
4230 //left bomb rubble
4231
2/2
✓ Branch 0 taken 17160 times.
✓ Branch 1 taken 5720 times.
22880 for(int32_t j=0; j<3; j++)
4232 {
4233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17160 times.
17160 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4234 {
4235 return qe_invalid;
4236 }
4237 17160 }
4238
4239
2/2
✓ Branch 0 taken 17160 times.
✓ Branch 1 taken 5720 times.
22880 for(int32_t j=0; j<3; j++)
4240 {
4241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17160 times.
17160 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4242 {
4243 return qe_invalid;
4244 }
4245 17160 }
4246
4247
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 40 times.
5720 if(Header->zelda_version < 0x193)
4248 {
4249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4250 {
4251 return qe_invalid;
4252 }
4253
4254 40 }
4255
4256 //right bomb rubble
4257
2/2
✓ Branch 0 taken 17160 times.
✓ Branch 1 taken 5720 times.
22880 for(int32_t j=0; j<3; j++)
4258 {
4259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17160 times.
17160 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4260 {
4261 return qe_invalid;
4262 }
4263 17160 }
4264
4265
2/2
✓ Branch 0 taken 17160 times.
✓ Branch 1 taken 5720 times.
22880 for(int32_t j=0; j<3; j++)
4266 {
4267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17160 times.
17160 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4268 {
4269 return qe_invalid;
4270 }
4271 17160 }
4272
4273
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 40 times.
5720 if(Header->zelda_version < 0x193)
4274 {
4275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4276 {
4277 return qe_invalid;
4278 }
4279 40 }
4280
4281 //walkthrough stuff
4282
2/2
✓ Branch 0 taken 22880 times.
✓ Branch 1 taken 5720 times.
28600 for(int32_t j=0; j<4; j++)
4283 {
4284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22880 times.
22880 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4285 {
4286 return qe_invalid;
4287 }
4288 22880 }
4289
4290
2/2
✓ Branch 0 taken 22880 times.
✓ Branch 1 taken 5720 times.
28600 for(int32_t j=0; j<4; j++)
4291 {
4292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22880 times.
22880 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4293 {
4294 return qe_invalid;
4295 }
4296 22880 }
4297
4298 //flags
4299
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 5720 times.
17160 for(int32_t j=0; j<2; j++)
4300 {
4301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11440 times.
11440 if(!p_getc(&tempDoorComboSet.flags[j],f))
4302 {
4303 return qe_invalid;
4304 }
4305 11440 }
4306
4307
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 40 times.
5720 if(Header->zelda_version < 0x193)
4308 {
4309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4310 {
4311 return qe_invalid;
4312 }
4313 40 }
4314
4315
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5706 times.
5720 if (!should_skip)
4316 5706 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4317 5720 }
4318
4319
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 479 times.
480 if (!should_skip)
4320 479 door_combo_set_count=temp_door_combo_set_count;
4321
4322 480 return 0;
4323 498 }
4324
4325 9 int32_t count_dmaps()
4326 {
4327 9 int32_t i=MAXDMAPS-1;
4328 9 bool found=false;
4329
4330
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4331 {
4332
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4333
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].music!=0)||
4334
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4335 18 found=true;
4336
4337
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4338 {
4339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4340
4341 found=true;
4342 72 }
4343
4344
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4345 (DMaps[i].intro[0]!=0))
4346 27 found=true;
4347
4348
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_tile[0]!=0)||(DMaps[i].minimap_tile[1]!=0)||
4349
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_tile[0]!=0)||(DMaps[i].largemap_tile[1]!=0)||
4350
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_cset[0]!=0)||(DMaps[i].minimap_cset[1]!=0)||
4351
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_cset[0]!=0)||(DMaps[i].largemap_cset[1]!=0))
4352 18 found=true;
4353
4354 if(!found)
4355 {
4356 i--;
4357 }
4358 }
4359
4360 9 return i+1;
4361 }
4362
4363
4364 9 int32_t count_shops(miscQdata *Misc)
4365 {
4366 9 int32_t i=NUM_SHOPS-1,j;
4367 9 bool found=false;
4368
4369
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4370 {
4371 2229 j=2;
4372
4373
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4374 {
4375
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4376 {
4377 5 found=true;
4378 5 }
4379 else
4380 {
4381 6672 j--;
4382 }
4383 }
4384
4385
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4386 {
4387 found=true;
4388 }
4389
4390
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4391 {
4392 2224 i--;
4393 2224 }
4394 }
4395
4396 9 return i+1;
4397 }
4398
4399 9 int32_t count_infos(miscQdata *Misc)
4400 {
4401 9 int32_t i=255,j;
4402 9 bool found=false;
4403
4404
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4405 {
4406 2229 j=2;
4407
4408
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4409 {
4410
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4411 {
4412 5 found=true;
4413 5 }
4414 else
4415 {
4416 6672 j--;
4417 }
4418 }
4419
4420
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4421 {
4422 found=true;
4423 }
4424
4425
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4426 {
4427 2224 i--;
4428 2224 }
4429 }
4430
4431 9 return i+1;
4432 }
4433
4434 9 int32_t count_warprings(miscQdata *Misc)
4435 {
4436 9 int32_t i=15,j;
4437 9 bool found=false;
4438
4439
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4440 {
4441 49 j=7;
4442
4443
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4444 {
4445
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4446 {
4447 9 found=true;
4448 9 }
4449 else
4450 {
4451 349 j--;
4452 }
4453 }
4454
4455
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4456 {
4457 40 i--;
4458 40 }
4459 }
4460
4461 9 return i+1;
4462 }
4463
4464 9 int32_t count_palcycles(miscQdata *Misc)
4465 {
4466 9 int32_t i=255,j;
4467 9 bool found=false;
4468
4469
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4470 {
4471 2036 j=2;
4472
4473
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4474 {
4475
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4476 {
4477 7 found=true;
4478 7 }
4479 else
4480 {
4481 6087 j--;
4482 }
4483 }
4484
4485
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4486 {
4487 2029 i--;
4488 2029 }
4489 }
4490
4491 9 return i+1;
4492 }
4493
4494 192168 void clear_screen(mapscr *temp_scr)
4495 {
4496 192168 temp_scr->zero_memory();
4497 192168 }
4498
4499 // NOTE: when modifying this, you need to also update:
4500 // readdmaps, and FFScript::read_dmaps
4501 // (and their associated write functions)
4502
4503 232768 int32_t read_one_dmap(PACKFILE* f, zquestheader *Header, int s_version, int index)
4504 {
4505
2/2
✓ Branch 0 taken 230656 times.
✓ Branch 1 taken 2112 times.
232768 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4506 232768 dmap tempDMap;
4507
3/4
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 232385 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 383 times.
232768 static AdvancedMusic tempMusic;
4508 char legacy_title[22];
4509 byte padding;
4510
4511
2/2
✓ Branch 0 taken 162112 times.
✓ Branch 1 taken 70656 times.
232768 if (s_version < 25)
4512
1/2
✓ Branch 0 taken 162112 times.
✗ Branch 1 not taken.
162112 tempMusic.clear();
4513
4514
2/2
✓ Branch 0 taken 229440 times.
✓ Branch 1 taken 3328 times.
232768 if (!should_skip)
4515 {
4516
1/2
✓ Branch 0 taken 229440 times.
✗ Branch 1 not taken.
229440 DMaps[index].clear();
4517 229440 DMaps[index].type |= dmCAVE;
4518 229440 }
4519
4520 {
4521
2/2
✓ Branch 0 taken 229696 times.
✓ Branch 1 taken 3072 times.
232768 tempDMap.clear();
4522 229696 sprintf(legacy_title," ");
4523 229696 sprintf(tempDMap.intro," ");
4524
4525
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.map,f))
4526 {
4527 return qe_invalid;
4528 }
4529
4530
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 212480 times.
229696 if(s_version <= 4)
4531 {
4532 byte tempbyte;
4533
4534
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4535 {
4536 return qe_invalid;
4537 }
4538
4539 17216 tempDMap.level=(word)tempbyte;
4540 17216 }
4541 else
4542 {
4543
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_igetw(&tempDMap.level,f))
4544 {
4545 return qe_invalid;
4546 }
4547 }
4548
4549
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.xoff,f))
4550 {
4551 return qe_invalid;
4552 }
4553
4554
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.compass,f))
4555 {
4556 return qe_invalid;
4557 }
4558
4559
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version > 8) // February 2009
4560 {
4561
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_igetw(&tempDMap.color,f))
4562 {
4563 return qe_invalid;
4564 }
4565 212480 }
4566 else
4567 {
4568 byte tempbyte;
4569
4570
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4571 {
4572 return qe_invalid;
4573 }
4574
4575 17216 tempDMap.color = (word)tempbyte;
4576 }
4577
4578
2/2
✓ Branch 0 taken 162112 times.
✓ Branch 1 taken 67584 times.
229696 if (s_version < 25)
4579 {
4580
2/4
✓ Branch 0 taken 162112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162112 times.
✗ Branch 3 not taken.
162112 if(!p_getc(&padding,f))
4581 return qe_invalid;
4582
1/2
✓ Branch 0 taken 162112 times.
✗ Branch 1 not taken.
162112 tempMusic.midi = convert_from_old_midi_id(padding + (MIDIOFFSET_DMAP-MIDIOFFSET_ZSCRIPT));
4583 162112 }
4584
4585
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.cont,f))
4586 {
4587 return qe_invalid;
4588 }
4589
4590
2/4
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229696 times.
✗ Branch 3 not taken.
229696 if(!p_getc(&tempDMap.type,f))
4591 {
4592 return qe_invalid;
4593 }
4594
4595
4/4
✓ Branch 0 taken 6354 times.
✓ Branch 1 taken 223342 times.
✓ Branch 2 taken 6310 times.
✓ Branch 3 taken 44 times.
236050 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4596
1/2
✓ Branch 0 taken 6354 times.
✗ Branch 1 not taken.
6354 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4597 6310 tempDMap.xoff = 0;
4598
4599
2/2
✓ Branch 0 taken 229696 times.
✓ Branch 1 taken 1837568 times.
2067264 for(int32_t j=0; j<8; j++)
4600 {
4601
2/4
✓ Branch 0 taken 1837568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1837568 times.
✗ Branch 3 not taken.
1837568 if(!p_getc(&tempDMap.grid[j],f))
4602 {
4603 return qe_invalid;
4604 }
4605 1837568 }
4606
4607
5/6
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 227584 times.
229696 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4608 {
4609
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4610 {
4611 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4612 127 }
4613
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4614
4615
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(index==0 && Header->zelda_version <= 0x190)
4616 {
4617
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4618
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4619 18 }
4620
4621 //forgotten -DD
4622
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4623 {
4624 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4625 439 }
4626 576 }
4627 else
4628 {
4629
3/4
✓ Branch 0 taken 229120 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
227584 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4630 {
4631 return qe_invalid;
4632 }
4633
4634
2/2
✓ Branch 0 taken 127744 times.
✓ Branch 1 taken 101376 times.
229120 if(s_version<20)
4635 {
4636
2/4
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127744 times.
✗ Branch 3 not taken.
127744 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4637 {
4638 return qe_invalid;
4639 }
4640
1/2
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
127744 tempDMap.title.assign(legacy_title);
4641 127744 }
4642 else
4643 {
4644
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if (!p_getwstr(&tempDMap.title, f))
4645 {
4646 return qe_invalid;
4647 }
4648 }
4649
4650
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4651 {
4652 return qe_invalid;
4653 }
4654
4655
5/8
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 227584 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
229120 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4656 {
4657 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4658 DMaps[index] = tempDMap;
4659
4660 return 0;
4661 }
4662
4663
3/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 227584 times.
229120 if(Header && (Header->zelda_version < 0x193))
4664 {
4665
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4666 {
4667 return qe_invalid;
4668 }
4669 1536 }
4670
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119040 times.
229120 if ( s_version >= 11 )
4671 {
4672
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetl(&tempDMap.minimap_tile[0],f))
4673 {
4674 return qe_invalid;
4675 }
4676 110080 }
4677 else
4678 {
4679
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[0],f))
4680 {
4681 return qe_invalid;
4682 }
4683 }
4684
4685
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getc(&tempDMap.minimap_cset[0],f))
4686 {
4687 return qe_invalid;
4688 }
4689
4690
3/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 227584 times.
229120 if(Header && (Header->zelda_version < 0x193))
4691 {
4692
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4693 {
4694 return qe_invalid;
4695 }
4696 1536 }
4697
4698
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119040 times.
229120 if ( s_version >= 11 )
4699 {
4700
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetl(&tempDMap.minimap_tile[1],f))
4701 {
4702 return qe_invalid;
4703 }
4704 110080 }
4705 else
4706 {
4707
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[1],f))
4708 {
4709 return qe_invalid;
4710 }
4711 }
4712
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getc(&tempDMap.minimap_cset[1],f))
4713 {
4714 return qe_invalid;
4715 }
4716
4717
3/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 227584 times.
229120 if(Header && (Header->zelda_version < 0x193))
4718 {
4719
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4720 {
4721 return qe_invalid;
4722 }
4723 1536 }
4724
4725
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119040 times.
229120 if ( s_version >= 11 )
4726 {
4727
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetl(&tempDMap.largemap_tile[0],f))
4728 {
4729 return qe_invalid;
4730 }
4731 110080 }
4732 else
4733 {
4734
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[0],f))
4735 {
4736 return qe_invalid;
4737 }
4738 }
4739
4740
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getc(&tempDMap.largemap_cset[0],f))
4741 {
4742 return qe_invalid;
4743 }
4744
4745
3/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 227584 times.
229120 if(Header && (Header->zelda_version < 0x193))
4746 {
4747
4748
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4749 {
4750 return qe_invalid;
4751 }
4752 1536 }
4753
4754
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119040 times.
229120 if ( s_version >= 11 )
4755 {
4756
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetl(&tempDMap.largemap_tile[1],f))
4757 {
4758 return qe_invalid;
4759 }
4760 110080 }
4761 else
4762 {
4763
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[1],f))
4764 {
4765 return qe_invalid;
4766 }
4767 }
4768
2/4
✓ Branch 0 taken 229120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229120 times.
✗ Branch 3 not taken.
229120 if(!p_getc(&tempDMap.largemap_cset[1],f))
4769 {
4770 return qe_invalid;
4771 }
4772
4773
2/2
✓ Branch 0 taken 161536 times.
✓ Branch 1 taken 67584 times.
229120 if (s_version < 25)
4774 {
4775 161536 char tmusic[57] = {0};
4776
2/4
✓ Branch 0 taken 161536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 161536 times.
✗ Branch 3 not taken.
161536 if(!p_getstr(tmusic,sizeof(tmusic)-1,f))
4777 return qe_invalid;
4778
1/2
✓ Branch 0 taken 161536 times.
✗ Branch 1 not taken.
161536 tempMusic.enhanced.path = tmusic;
4779 161536 }
4780 }
4781
4782
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version>1)
4783 {
4784
2/2
✓ Branch 0 taken 144896 times.
✓ Branch 1 taken 67584 times.
212480 if (s_version < 25)
4785
2/4
✓ Branch 0 taken 144896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144896 times.
✗ Branch 3 not taken.
144896 if(!p_getc(&tempMusic.enhanced.track,f))
4786 return qe_invalid;
4787
4788
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_getc(&tempDMap.active_subscreen,f))
4789 {
4790 return qe_invalid;
4791 }
4792
4793
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_getc(&tempDMap.passive_subscreen,f))
4794 {
4795 return qe_invalid;
4796 }
4797 212480 }
4798
4799
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version>2)
4800 {
4801 byte di[32];
4802
4803
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!pfread(&di, 32, f)) return qe_invalid;
4804
4805
2/2
✓ Branch 0 taken 54394880 times.
✓ Branch 1 taken 212480 times.
54607360 for(int32_t j=0; j<MAXITEMS; j++)
4806 {
4807
2/2
✓ Branch 0 taken 9207 times.
✓ Branch 1 taken 54385673 times.
54394880 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4808 54385673 else tempDMap.disableditems[j]=0;
4809 54394880 }
4810 212480 }
4811
4812
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version >= 6)
4813 {
4814
2/4
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212480 times.
✗ Branch 3 not taken.
212480 if(!p_igetl(&tempDMap.flags,f))
4815 {
4816 return qe_invalid;
4817 }
4818 212480 }
4819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4820 {
4821 char temp;
4822
4823 if(!p_getc(&temp,f))
4824 {
4825 return qe_invalid;
4826 }
4827
4828 tempDMap.flags = temp;
4829 }
4830
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4831 {
4832 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4833 8992 }
4834 else
4835 8224 tempDMap.flags=0;
4836
4837
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version<7)
4838 {
4839
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6146 times.
✓ Branch 5 taken 2846 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4840 6146 tempDMap.flags|= dmfVIEWMAP;
4841 17216 }
4842
4843
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 17216 times.
229696 if(s_version<8)
4844 {
4845
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4846 {
4847
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4848 8050 tempDMap.type |= dmCAVE;
4849 8050 }
4850
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4851 {
4852 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4853 2332 }
4854 17216 }
4855
4856
7/8
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 227584 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 227584 times.
229696 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4857 229120 && (Header->zelda_version < 0x193))
4858 {
4859
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4860 {
4861 return qe_invalid;
4862 }
4863 1536 }
4864
4865
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 110080 times.
229696 if(s_version >= 10)
4866 {
4867
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_getc(&tempDMap.sideview,f))
4868 {
4869 return qe_invalid;
4870 }
4871 110080 }
4872
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if(s_version < 10) tempDMap.sideview = 0;
4873
4874 //Dmap Scripts
4875
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if(s_version >= 12)
4876 {
4877
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetw(&tempDMap.script,f))
4878 {
4879 return qe_invalid;
4880 }
4881
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; q++ )
4882 {
4883
2/4
✓ Branch 0 taken 880640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880640 times.
✗ Branch 3 not taken.
880640 if(!p_igetl(&tempDMap.initD[q],f))
4884 {
4885 return qe_invalid;
4886 }
4887 880640 }
4888 110080 }
4889
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if ( s_version < 12 )
4890 {
4891 119616 tempDMap.script = 0;
4892
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4893 {
4894 956928 tempDMap.initD[q] = 0;
4895 956928 }
4896 119616 }
4897
4898
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 110080 times.
229696 if(s_version >= 13)
4899 {
4900
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; q++ )
4901 {
4902
2/2
✓ Branch 0 taken 57241600 times.
✓ Branch 1 taken 880640 times.
58122240 for ( int32_t w = 0; w < 65; w++ )
4903 {
4904
2/4
✓ Branch 0 taken 57241600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57241600 times.
✗ Branch 3 not taken.
57241600 if(!p_getc(&tempDMap.initD_label[q][w],f))
4905 {
4906 return qe_invalid;
4907 }
4908 57241600 }
4909 880640 }
4910 110080 }
4911
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if ( s_version < 13 )
4912 {
4913 119616 tempDMap.script = 0;
4914
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4915 {
4916
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for ( int32_t w = 0; w < 65; w++ )
4917 62200320 tempDMap.initD_label[q][w] = 0;
4918 956928 }
4919 119616 }
4920
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if(s_version >= 14)
4921 {
4922
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetw(&tempDMap.active_sub_script,f))
4923 {
4924 return qe_invalid;
4925 }
4926
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetw(&tempDMap.passive_sub_script,f))
4927 {
4928 return qe_invalid;
4929 }
4930
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; ++q )
4931 {
4932
2/4
✓ Branch 0 taken 880640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880640 times.
✗ Branch 3 not taken.
880640 if(!p_igetl(&tempDMap.sub_initD[q],f))
4933 {
4934 return qe_invalid;
4935 }
4936 880640 }
4937
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for(int32_t q = 0; q < 8; ++q)
4938 {
4939
2/2
✓ Branch 0 taken 57241600 times.
✓ Branch 1 taken 880640 times.
58122240 for ( int32_t w = 0; w < 65; ++w )
4940 {
4941
2/4
✓ Branch 0 taken 57241600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57241600 times.
✗ Branch 3 not taken.
57241600 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4942 {
4943 return qe_invalid;
4944 }
4945 57241600 }
4946 880640 }
4947 110080 }
4948 else
4949 {
4950 119616 tempDMap.active_sub_script = 0;
4951 119616 tempDMap.passive_sub_script = 0;
4952
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
4953 {
4954 956928 tempDMap.sub_initD[q] = 0;
4955
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
4956 62200320 tempDMap.sub_initD_label[q][w] = 0;
4957 956928 }
4958 }
4959
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if(s_version >= 15)
4960 {
4961
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetw(&tempDMap.onmap_script,f))
4962 {
4963 return qe_invalid;
4964 }
4965
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; ++q )
4966 {
4967
2/4
✓ Branch 0 taken 880640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880640 times.
✗ Branch 3 not taken.
880640 if(!p_igetl(&tempDMap.onmap_initD[q],f))
4968 {
4969 return qe_invalid;
4970 }
4971 880640 }
4972
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for(int32_t q = 0; q < 8; ++q)
4973 {
4974
2/2
✓ Branch 0 taken 57241600 times.
✓ Branch 1 taken 880640 times.
58122240 for ( int32_t w = 0; w < 65; ++w )
4975 {
4976
2/4
✓ Branch 0 taken 57241600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57241600 times.
✗ Branch 3 not taken.
57241600 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
4977 {
4978 return qe_invalid;
4979 }
4980 57241600 }
4981 880640 }
4982 110080 }
4983 else
4984 {
4985 119616 tempDMap.onmap_script = 0;
4986
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
4987 {
4988 956928 tempDMap.onmap_initD[q] = 0;
4989
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
4990 {
4991 62200320 tempDMap.onmap_initD_label[q][w] = 0;
4992 62200320 }
4993 956928 }
4994 }
4995
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 119616 times.
229696 if(s_version >= 16)
4996 {
4997
2/4
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
110080 if(!p_igetw(&tempDMap.mirrorDMap,f))
4998 {
4999 return qe_invalid;
5000 }
5001 110080 }
5002 else
5003 {
5004 119616 tempDMap.mirrorDMap = -1;
5005 }
5006
5007 // Enhanced music loop points
5008
4/4
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 128320 times.
✓ Branch 2 taken 33792 times.
✓ Branch 3 taken 67584 times.
229696 if (s_version >= 18 && s_version < 25)
5009 {
5010
2/4
✓ Branch 0 taken 33792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33792 times.
✗ Branch 3 not taken.
33792 if (!p_igetl(&tempMusic.enhanced.loop_start, f))
5011 return qe_invalid;
5012
2/4
✓ Branch 0 taken 33792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33792 times.
✗ Branch 3 not taken.
33792 if (!p_igetl(&tempMusic.enhanced.loop_end, f))
5013 return qe_invalid;
5014
2/4
✓ Branch 0 taken 33792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33792 times.
✗ Branch 3 not taken.
33792 if (!p_igetl(&tempMusic.enhanced.xfade_in, f))
5015 return qe_invalid;
5016
2/4
✓ Branch 0 taken 33792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33792 times.
✗ Branch 3 not taken.
33792 if (!p_igetl(&tempMusic.enhanced.xfade_out, f))
5017 return qe_invalid;
5018 33792 }
5019
5020
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 128320 times.
229696 if(s_version >= 19)
5021
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_getc(&tempDMap.overlay_subscreen, f))
5022 return qe_invalid;
5023
5024
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 128320 times.
229696 if (s_version >= 20)
5025 {
5026
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if (!p_igetl(&tempDMap.intro_string_id, f))
5027 return qe_invalid;
5028 101376 }
5029 else
5030 128320 tempDMap.intro_string_id = 0;
5031
5032
2/2
✓ Branch 0 taken 214848 times.
✓ Branch 1 taken 14848 times.
229696 if(s_version == 21)
5033 {
5034 static regions_data tmp_rd;
5035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
5036
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for(int32_t j=0; j<8; j++)
5037 {
5038
2/2
✓ Branch 0 taken 950272 times.
✓ Branch 1 taken 118784 times.
1069056 for(int32_t k=0; k<8; k++)
5039 {
5040
2/4
✓ Branch 0 taken 950272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 950272 times.
✗ Branch 3 not taken.
950272 if(!p_getc(&rd.region_ids[j][k],f))
5041 {
5042 return qe_invalid;
5043 }
5044 950272 }
5045 118784 }
5046 14848 }
5047
5048
3/4
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 151360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78336 times.
229696 if (s_version > 22 && (tempDMap.flags & dmfCUSTOM_GRAVITY))
5049 {
5050 if (!p_igetzf(&tempDMap.dmap_gravity, f))
5051 return qe_invalid;
5052 if (!p_igetzf(&tempDMap.dmap_terminal_v, f))
5053 return qe_invalid;
5054 }
5055
2/2
✓ Branch 0 taken 68096 times.
✓ Branch 1 taken 161600 times.
229696 if(s_version > 23)
5056 {
5057
2/4
✓ Branch 0 taken 68096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68096 times.
✗ Branch 3 not taken.
68096 if(!p_igetw(&tempDMap.map_subscreen, f))
5058 return qe_invalid;
5059
2/4
✓ Branch 0 taken 68096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68096 times.
✗ Branch 3 not taken.
68096 if(!p_getc(&tempDMap.floor, f))
5060 return qe_invalid;
5061 68096 }
5062
2/2
✓ Branch 0 taken 67584 times.
✓ Branch 1 taken 162112 times.
229696 if (s_version >= 25)
5063 {
5064
2/4
✓ Branch 0 taken 67584 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67584 times.
✗ Branch 3 not taken.
67584 if (!p_igetw(&tempDMap.music, f))
5065 return qe_invalid;
5066 67584 }
5067
2/2
✓ Branch 0 taken 161856 times.
✓ Branch 1 taken 256 times.
162112 else if (!should_skip) // add an AdvancedMusic to the quest
5068 {
5069
3/4
✓ Branch 0 taken 161856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19264 times.
✓ Branch 3 taken 142592 times.
161856 if (tempMusic.is_empty())
5070 142592 tempDMap.music = 0;
5071 else
5072 {
5073
1/2
✓ Branch 0 taken 19264 times.
✗ Branch 1 not taken.
19264 tempMusic.name = fmt::format("DMap {}", index);
5074
1/2
✓ Branch 0 taken 19264 times.
✗ Branch 1 not taken.
19264 auto& ref = quest_music.emplace_back(tempMusic);
5075 19264 tempDMap.music = word(quest_music.size());
5076 19264 ref.id = tempDMap.music;
5077 }
5078 161856 }
5079
5080
2/2
✓ Branch 0 taken 229440 times.
✓ Branch 1 taken 256 times.
229696 if (!should_skip)
5081 {
5082
1/2
✓ Branch 0 taken 229440 times.
✗ Branch 1 not taken.
229440 if(loading_tileset_flags & TILESET_CLEARMAPS)
5083 tempDMap.map = 0;
5084
1/2
✓ Branch 0 taken 229440 times.
✗ Branch 1 not taken.
229440 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5085 {
5086 tempDMap.script = 0;
5087 for(int q = 0; q < 8; ++q)
5088 tempDMap.initD[q] = 0;
5089 }
5090
1/2
✓ Branch 0 taken 229440 times.
✗ Branch 1 not taken.
229440 DMaps[index] = tempDMap;
5091 229440 }
5092 }
5093 229696 return 0;
5094 235840 }
5095 498 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
5096 {
5097
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
5098
5099 498 word dmapstoread=0;
5100
5101 int32_t dummy;
5102 498 word s_version=0;
5103
5104
3/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 497 times.
✗ Branch 3 not taken.
498 if (!should_skip && s_version == 21)
5105 Regions = {};
5106
5107 498 Header->is_z3 = false;
5108
3/4
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 24 times.
498 if(!Header || Header->zelda_version > 0x192)
5109 {
5110 //section version info
5111
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&s_version,f))
5112 {
5113 return qe_invalid;
5114 }
5115
5116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (s_version > V_DMAPS)
5117 return qe_version;
5118
5119 474 Header->is_z3 = s_version >= 22;
5120 474 FFCore.quest_format[vDMaps] = s_version;
5121
5122
5123
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!read_deprecated_section_cversion(f))
5124 {
5125 return qe_invalid;
5126 }
5127
5128 //section size
5129
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
5130 {
5131 return qe_invalid;
5132 }
5133
5134 //finally... section data
5135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(!p_igetw(&dmapstoread,f))
5136 {
5137 return qe_invalid;
5138 }
5139 474 }
5140 else
5141 {
5142
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5143
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
5144 {
5145 18 dmapstoread=32;
5146 18 }
5147
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
5148 {
5149 6 dmapstoread=OLDMAXDMAPS;
5150 6 }
5151 else
5152 {
5153 dmapstoread=MAXDMAPS;
5154 }
5155 }
5156
5157
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 415 times.
498 dmapstoread = zc_min(dmapstoread, max_dmaps);
5158
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 415 times.
498 dmapstoread = zc_min(dmapstoread, MAXDMAPS-start_dmap);
5159
5160
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 366 times.
498 if (s_version < 25) // reserve space for the advanced music that will be created
5161 366 quest_music.reserve(quest_music.size() + dmapstoread);
5162
5163
2/2
✓ Branch 0 taken 229696 times.
✓ Branch 1 taken 498 times.
230194 for(int i = start_dmap; i < dmapstoread + start_dmap; ++i)
5164 {
5165
1/2
✓ Branch 0 taken 229696 times.
✗ Branch 1 not taken.
229696 if (int ret = read_one_dmap(f, Header, s_version, i))
5166 return ret;
5167 229696 }
5168
5169 498 return 0;
5170 498 }
5171
5172 415 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5173 {
5174 //these are here to bypass compiler warnings about unused arguments
5175 415 Header=Header;
5176
5177 415 miscQdata temp_misc;
5178 415 word s_version=0;
5179 415 int32_t tempsize=0;
5180 word dummyw;
5181
5182
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 temp_misc = *Misc;
5183
5184 //section version info
5185
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_igetw(&s_version,f))
5186 {
5187 return qe_invalid;
5188 }
5189
5190
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if (s_version > V_COLORS)
5191 return qe_version;
5192
5193 415 FFCore.quest_format[vColours] = s_version;
5194
5195
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 al_trace("Misc Colours section version: %d\n", s_version);
5196
5197
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!read_deprecated_section_cversion(f))
5198 {
5199 return qe_invalid;
5200 }
5201
5202
5203 //section size
5204
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_igetl(&tempsize,f))
5205 {
5206 return qe_invalid;
5207 }
5208
5209 //finally... section data
5210 415 readsize=0;
5211
5212
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.text,f))
5213 {
5214 return qe_invalid;
5215 }
5216
5217
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.caption,f))
5218 {
5219 return qe_invalid;
5220 }
5221
5222
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.overw_bg,f))
5223 {
5224 return qe_invalid;
5225 }
5226
5227
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5228 {
5229 return qe_invalid;
5230 }
5231
5232
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5233 {
5234 return qe_invalid;
5235 }
5236
5237
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.cave_fg,f))
5238 {
5239 return qe_invalid;
5240 }
5241
5242
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.bs_dk,f))
5243 {
5244 return qe_invalid;
5245 }
5246
5247
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.bs_goal,f))
5248 {
5249 return qe_invalid;
5250 }
5251
5252
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.compass_lt,f))
5253 {
5254 return qe_invalid;
5255 }
5256
5257
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.compass_dk,f))
5258 {
5259 return qe_invalid;
5260 }
5261
5262
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5263 {
5264 return qe_invalid;
5265 }
5266
5267
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.triframe_color,f))
5268 {
5269 return qe_invalid;
5270 }
5271
5272
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.hero_dot,f))
5273 {
5274 return qe_invalid;
5275 }
5276
5277
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5278 {
5279 return qe_invalid;
5280 }
5281
5282
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5283 {
5284 return qe_invalid;
5285 }
5286
5287
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5288 {
5289 return qe_invalid;
5290 }
5291
5292
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5293 {
5294 return qe_invalid;
5295 }
5296
5297
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5298 {
5299 return qe_invalid;
5300 }
5301
5302
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5303 {
5304 return qe_invalid;
5305 }
5306
5307
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5308 {
5309 return qe_invalid;
5310 }
5311
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version < 4)
5312 {
5313
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5314 return qe_invalid;
5315 200 temp_misc.colors.triforce_tile = dummyw;
5316
5317
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5318 return qe_invalid;
5319 200 temp_misc.colors.triframe_tile = dummyw;
5320
5321
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5322 return qe_invalid;
5323 200 temp_misc.colors.overworld_map_tile = dummyw;
5324
5325
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5326 return qe_invalid;
5327 200 temp_misc.colors.dungeon_map_tile = dummyw;
5328
5329
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5330 return qe_invalid;
5331 200 temp_misc.colors.blueframe_tile = dummyw;
5332
5333
2/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
200 if(!p_igetw(&dummyw,f))
5334 return qe_invalid;
5335 200 temp_misc.colors.HCpieces_tile = dummyw;
5336 200 }
5337
5338
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5339 {
5340 return qe_invalid;
5341 }
5342
5343
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5344 {
5345 return qe_invalid;
5346 }
5347
5348
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version < 2)
5349 {
5350 temp_misc.colors.msgtext = 0x01;
5351 }
5352 else
5353 {
5354
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_getc(&temp_misc.colors.msgtext, f))
5355 {
5356 return qe_invalid;
5357 }
5358 }
5359
5360
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if ( s_version >= 3 ) //expanded tile pages to 825
5361 {
5362
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5363 {
5364 return qe_invalid;
5365 }
5366
5367
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5368 {
5369 return qe_invalid;
5370 }
5371
5372
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5373 {
5374 return qe_invalid;
5375 }
5376
5377
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5378 {
5379 return qe_invalid;
5380 }
5381
5382
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5383 {
5384 return qe_invalid;
5385 }
5386
5387
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5388 {
5389 return qe_invalid;
5390 }
5391 215 }
5392
5393
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 *Misc = temp_misc;
5394
5395 415 return 0;
5396 415 }
5397
5398 415 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5399 {
5400 415 miscQdata temp_misc;
5401 415 word s_version=0;
5402 byte icons;
5403 415 int32_t tempsize=0;
5404
5405
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 temp_misc = *Misc;
5406
5407 //section version info
5408
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_igetw(&s_version,f))
5409 {
5410 return qe_invalid;
5411 }
5412
5413
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if (s_version > V_ICONS)
5414 return qe_version;
5415
5416 415 FFCore.quest_format[vIcons] = s_version;
5417
5418
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!read_deprecated_section_cversion(f))
5419 {
5420 return qe_invalid;
5421 }
5422
5423
5424 //section size
5425
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
415 if(!p_igetl(&tempsize,f))
5426 {
5427 return qe_invalid;
5428 }
5429
5430 //finally... section data
5431 415 readsize=0;
5432
5433 415 icons=4;
5434
5435
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if ( s_version >= 10 )
5436 {
5437
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<icons; i++)
5438 {
5439
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&temp_misc.icons[i],f))
5440 {
5441 return qe_invalid;
5442 }
5443 860 }
5444 215 }
5445 else
5446 {
5447
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<icons; i++)
5448 {
5449
2/4
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800 times.
✗ Branch 3 not taken.
800 if(!p_igetw(&temp_misc.icons[i],f))
5450 {
5451 return qe_invalid;
5452 }
5453 800 }
5454 }
5455
5456
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 *Misc = temp_misc;
5457
5458 415 return 0;
5459 415 }
5460
5461 1420 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5462 {
5463
2/2
✓ Branch 0 taken 1396 times.
✓ Branch 1 taken 24 times.
1420 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5464
5465 1420 word maxinfos=256;
5466 1420 word maxshops=256;
5467 1420 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5468 1420 word ponds=16, pondsize=72, expansionsize=98*2;
5469 byte tempbyte, padding;
5470 1420 miscQdata temp_misc;
5471 1420 word s_version=0;
5472 word swaptmp;
5473 1420 int32_t tempsize=0;
5474
5475
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 588 times.
1420 temp_misc = *Misc;
5476
5477
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 832 times.
213824 for(int32_t i=0; i<maxshops; ++i)
5478 {
5479 212992 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5480 212992 }
5481
5482
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 832 times.
213824 for(int32_t i=0; i<maxinfos; ++i)
5483 {
5484 212992 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5485 212992 }
5486
5487 832 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5488
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 832 times.
27456 for (auto& sm : temp_misc.save_menus)
5489
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 sm.clear();
5490
5491
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(Header->zelda_version > 0x192)
5492 {
5493 //section version info
5494
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&s_version,f))
5495 {
5496 return qe_invalid;
5497 }
5498
5499
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if (s_version > V_MISC)
5500 return qe_version;
5501
5502 808 FFCore.quest_format[vMisc] = s_version;
5503
5504
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!read_deprecated_section_cversion(f))
5505 {
5506 return qe_invalid;
5507 }
5508
5509
5510 //section size
5511
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetl(&tempsize,f))
5512 {
5513 return qe_invalid;
5514 }
5515 808 }
5516
5517 //finally... section data
5518 832 readsize=0;
5519
5520 //shops
5521
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(Header->zelda_version > 0x192)
5522 {
5523
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&shops,f))
5524 {
5525 return qe_invalid;
5526 }
5527 808 }
5528
5529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (shops > NUM_SHOPS)
5530 {
5531 return qe_invalid;
5532 }
5533
5534
2/2
✓ Branch 0 taken 11390 times.
✓ Branch 1 taken 832 times.
12222 for(int32_t i=0; i<shops; i++)
5535 {
5536
2/2
✓ Branch 0 taken 10190 times.
✓ Branch 1 taken 1200 times.
11390 if(s_version > 6)
5537 {
5538
2/4
✓ Branch 0 taken 10190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10190 times.
10190 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5539 {
5540 return qe_invalid;
5541 }
5542 10190 }
5543
5544
2/2
✓ Branch 0 taken 34170 times.
✓ Branch 1 taken 11390 times.
45560 for(int32_t j=0; j<3; j++)
5545 {
5546
2/4
✓ Branch 0 taken 34170 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34170 times.
34170 if(!p_getc(&temp_misc.shop[i].item[j],f))
5547 {
5548 return qe_invalid;
5549 }
5550
5551
2/2
✓ Branch 0 taken 30570 times.
✓ Branch 1 taken 3600 times.
34170 if(s_version < 4)
5552 {
5553 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5554 3600 }
5555 34170 }
5556
5557
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 11006 times.
11390 if(Header->zelda_version < 0x193)
5558 {
5559
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&tempbyte,f))
5560 {
5561 return qe_invalid;
5562 }
5563 384 }
5564
5565
2/2
✓ Branch 0 taken 34170 times.
✓ Branch 1 taken 11390 times.
45560 for(int32_t j=0; j<3; j++)
5566 {
5567
2/4
✓ Branch 0 taken 34170 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34170 times.
34170 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5568 {
5569 return qe_invalid;
5570 }
5571 34170 }
5572
5573
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 10190 times.
11390 if(s_version > 3)
5574 {
5575
2/2
✓ Branch 0 taken 30570 times.
✓ Branch 1 taken 10190 times.
40760 for(int32_t j=0; j<3; j++)
5576 {
5577
2/4
✓ Branch 0 taken 30570 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30570 times.
✗ Branch 3 not taken.
30570 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5578 return qe_invalid;
5579 30570 }
5580 10190 }
5581
5582 /*
5583 if(s_version < 8)
5584 {
5585 for(int32_t j=0; j<3; j++)
5586 {
5587 (&temp_misc.shop[i].str[j])=0; //initialise.
5588 }
5589 }
5590 */
5591 11390 }
5592
5593 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5594
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 832 times.
213824 for(int32_t i=0; i<maxshops; ++i)
5595 {
5596
2/2
✓ Branch 0 taken 425984 times.
✓ Branch 1 taken 212992 times.
638976 for(int32_t j=0; j<3-1; j++)
5597 {
5598
2/2
✓ Branch 0 taken 638976 times.
✓ Branch 1 taken 425984 times.
1064960 for(int32_t k=0; k<2-j; k++)
5599 {
5600
2/2
✓ Branch 0 taken 24517 times.
✓ Branch 1 taken 614459 times.
638976 if(temp_misc.shop[i].hasitem[k]==0)
5601 {
5602 614459 swaptmp = temp_misc.shop[i].item[k];
5603 614459 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5604 614459 temp_misc.shop[i].item[k+1] = swaptmp;
5605 614459 swaptmp = temp_misc.shop[i].price[k];
5606 614459 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5607 614459 temp_misc.shop[i].price[k+1] = swaptmp;
5608 614459 swaptmp = temp_misc.shop[i].hasitem[k];
5609 614459 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5610 614459 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5611 614459 }
5612 638976 }
5613 425984 }
5614 212992 }
5615
5616 //infos
5617
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(Header->zelda_version > 0x192)
5618 {
5619
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&infos,f))
5620 {
5621 return qe_invalid;
5622 }
5623 808 }
5624
5625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (infos > NUM_INFOS)
5626 {
5627 return qe_invalid;
5628 }
5629
5630
5631
2/2
✓ Branch 0 taken 10696 times.
✓ Branch 1 taken 832 times.
11528 for(int32_t i=0; i<infos; i++)
5632 {
5633
2/2
✓ Branch 0 taken 9935 times.
✓ Branch 1 taken 761 times.
10696 if(s_version > 6)
5634 {
5635
2/4
✓ Branch 0 taken 9935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9935 times.
9935 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5636 {
5637 return qe_invalid;
5638 }
5639 9935 }
5640
5641
2/2
✓ Branch 0 taken 32088 times.
✓ Branch 1 taken 10696 times.
42784 for(int32_t j=0; j<3; j++)
5642 {
5643
2/2
✓ Branch 0 taken 31224 times.
✓ Branch 1 taken 864 times.
32376 if((Header->zelda_version < 0x192)||
5644
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 30936 times.
31224 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5645 {
5646
3/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
1152 if(!p_getc(&tempbyte,f))
5647 {
5648 return qe_invalid;
5649 }
5650
5651 864 temp_misc.info[i].str[j]=tempbyte;
5652 864 }
5653 else
5654 {
5655
3/4
✓ Branch 0 taken 31224 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 31224 times.
✗ Branch 3 not taken.
30936 if(!p_igetw(&temp_misc.info[i].str[j],f))
5656 {
5657 return qe_invalid;
5658 }
5659 }
5660 32088 }
5661
5662
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 10312 times.
10696 if(Header->zelda_version < 0x193)
5663 {
5664
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&tempbyte,f))
5665 {
5666 return qe_invalid;
5667 }
5668 384 }
5669
5670
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 10600 times.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
10696 if((Header->zelda_version == 0x192)&&(Header->build>145))
5671 {
5672
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&padding,f))
5673 {
5674 return qe_invalid;
5675 }
5676 96 }
5677
5678
2/2
✓ Branch 0 taken 32088 times.
✓ Branch 1 taken 10696 times.
42784 for(int32_t j=0; j<3; j++)
5679 {
5680
2/4
✓ Branch 0 taken 32088 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32088 times.
32088 if(!p_igetw(&temp_misc.info[i].price[j],f))
5681 {
5682 return qe_invalid;
5683 }
5684 32088 }
5685 10696 }
5686
5687 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5688
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 832 times.
213824 for(int32_t i=0; i<maxinfos; ++i)
5689 {
5690
2/2
✓ Branch 0 taken 425984 times.
✓ Branch 1 taken 212992 times.
638976 for(int32_t j=0; j<3-1; j++)
5691 {
5692
2/2
✓ Branch 0 taken 638976 times.
✓ Branch 1 taken 425984 times.
1064960 for(int32_t k=0; k<2-j; k++)
5693 {
5694
2/2
✓ Branch 0 taken 626864 times.
✓ Branch 1 taken 12112 times.
638976 if(temp_misc.info[i].str[k]==0)
5695 {
5696 626864 swaptmp = temp_misc.info[i].str[k];
5697 626864 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5698 626864 temp_misc.info[i].str[k+1] = swaptmp;
5699 626864 swaptmp = temp_misc.info[i].price[k];
5700 626864 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5701 626864 temp_misc.info[i].price[k+1] = swaptmp;
5702 626864 }
5703 638976 }
5704 425984 }
5705 212992 }
5706
5707
5708 //warp rings
5709
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 749 times.
832 if(s_version > 5)
5710 749 warprings++;
5711
5712
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(Header->zelda_version > 0x192)
5713 {
5714
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&warprings,f))
5715 {
5716 return qe_invalid;
5717 }
5718
5719
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 461 times.
808 if (warprings > NUM_WARP_RINGS)
5720 {
5721 // return qe_invalid;
5722 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5723 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5724 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5725 461 }
5726 808 }
5727
5728
2/2
✓ Branch 0 taken 8738 times.
✓ Branch 1 taken 832 times.
9570 for(int32_t i=0; i<warprings; i++)
5729 {
5730 // See above comment on the `warprings` range check.
5731 8738 bool keepdata = i < NUM_WARP_RINGS;
5732
5733
2/2
✓ Branch 0 taken 77522 times.
✓ Branch 1 taken 8738 times.
86260 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5734 {
5735
2/2
✓ Branch 0 taken 68562 times.
✓ Branch 1 taken 8960 times.
77522 if(s_version <= 3)
5736 {
5737
2/4
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8960 times.
✗ Branch 3 not taken.
8960 if(!p_getc(&tempbyte,f))
5738 {
5739 return qe_invalid;
5740 }
5741
5742
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5743 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5744 8960 }
5745 else
5746 {
5747 word tempword;
5748
2/4
✓ Branch 0 taken 68562 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68562 times.
68562 if(!p_igetw(&tempword,f))
5749 {
5750 return qe_invalid;
5751 }
5752
5753
2/2
✓ Branch 0 taken 8199 times.
✓ Branch 1 taken 60363 times.
68562 if (keepdata)
5754 60363 temp_misc.warp[i].dmap[j] = tempword;
5755 }
5756 77522 }
5757
5758
2/2
✓ Branch 0 taken 8738 times.
✓ Branch 1 taken 77522 times.
86260 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5759 {
5760
2/4
✓ Branch 0 taken 77522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77522 times.
✗ Branch 3 not taken.
77522 if(!p_getc(&tempbyte,f))
5761 {
5762 return qe_invalid;
5763 }
5764
2/2
✓ Branch 0 taken 11391 times.
✓ Branch 1 taken 66131 times.
77522 if (keepdata)
5765 66131 temp_misc.warp[i].scr[j] = tempbyte;
5766 77522 }
5767
5768
2/4
✓ Branch 0 taken 8738 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8738 times.
✗ Branch 3 not taken.
8738 if(!p_getc(&tempbyte,f))
5769 {
5770 return qe_invalid;
5771 }
5772
2/2
✓ Branch 0 taken 1310 times.
✓ Branch 1 taken 7428 times.
8738 if (keepdata)
5773 7428 temp_misc.warp[i].size = tempbyte;
5774
5775
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 8546 times.
8738 if(Header->zelda_version < 0x193)
5776 {
5777
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5778 {
5779 return qe_invalid;
5780 }
5781 192 }
5782 8738 }
5783
5784 //palette cycles
5785
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5786 {
5787
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5788 {
5789
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5790 {
5791 18432 temp_misc.cycles[i][j].first=0;
5792 18432 temp_misc.cycles[i][j].count=0;
5793 18432 temp_misc.cycles[i][j].speed=0;
5794 18432 }
5795 6144 }
5796
5797
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5798
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5799 {
5800 18 palcycles=16;
5801 18 }
5802
5803
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1824 times.
1848 for(int32_t i=0; i<palcycles; i++)
5804 {
5805
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 5472 times.
7296 for(int32_t j=0; j<3; j++)
5806 {
5807
2/4
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5472 times.
✗ Branch 3 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5808 {
5809 return qe_invalid;
5810 }
5811
5812
2/4
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5472 times.
✗ Branch 3 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5813 {
5814 return qe_invalid;
5815 }
5816
5817
2/4
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5818 {
5819 return qe_invalid;
5820 }
5821 5472 }
5822 1824 }
5823 24 }
5824
5825 //Wind warps are now just another warp ring.
5826
2/2
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 83 times.
832 if(s_version <= 5)
5827 {
5828
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version > 0x192)
5829 {
5830
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&windwarps,f))
5831 {
5832 return qe_invalid;
5833 }
5834 59 }
5835
5836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5837 {
5838 return qe_invalid;
5839 }
5840
5841
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 665 times.
748 for(int32_t i=0; i<windwarps; i++)
5842 {
5843
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5844 {
5845
2/4
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 665 times.
✗ Branch 3 not taken.
665 if(!p_getc(&tempbyte,f))
5846 {
5847 return qe_invalid;
5848 }
5849
5850 665 temp_misc.warp[8].dmap[i]=tempbyte;
5851 665 }
5852 else
5853 {
5854 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5855 {
5856 return qe_invalid;
5857 }
5858 }
5859
5860
2/4
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 665 times.
✗ Branch 3 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5861 {
5862 return qe_invalid;
5863 }
5864
5865 665 temp_misc.warp[8].size = 9;
5866
5867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 665 times.
665 if(s_version == 5)
5868 {
5869 if(!p_getc(&tempbyte,f))
5870 {
5871 return qe_invalid;
5872 }
5873 }
5874 665 }
5875 83 }
5876
5877
5878 //triforce pieces
5879
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 6656 times.
7488 for(int32_t i=0; i<triforces; i++)
5880 {
5881
2/4
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6656 times.
6656 if(!p_getc(&temp_misc.triforce[i],f))
5882 {
5883 return qe_invalid;
5884 }
5885 6656 }
5886
5887 //misc color data
5888
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 749 times.
832 if(s_version<3)
5889 {
5890
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5891 {
5892 return qe_invalid;
5893 }
5894
5895
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5896 {
5897 return qe_invalid;
5898 }
5899
5900
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5901 {
5902 return qe_invalid;
5903 }
5904
5905
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5906 {
5907 return qe_invalid;
5908 }
5909
5910
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5911 {
5912 return qe_invalid;
5913 }
5914
5915
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5916 {
5917 return qe_invalid;
5918 }
5919
5920
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5921 {
5922 return qe_invalid;
5923 }
5924
5925
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5926 {
5927 return qe_invalid;
5928 }
5929
5930
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5931 {
5932 return qe_invalid;
5933 }
5934
5935
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5936 {
5937 return qe_invalid;
5938 }
5939
5940
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5941 {
5942 return qe_invalid;
5943 }
5944
5945
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5946 {
5947 return qe_invalid;
5948 }
5949
5950
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5951 {
5952 return qe_invalid;
5953 }
5954
5955
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5956 {
5957 return qe_invalid;
5958 }
5959
5960
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5961 {
5962 return qe_invalid;
5963 }
5964
5965
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5966 {
5967 return qe_invalid;
5968 }
5969
5970
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5971 {
5972 return qe_invalid;
5973 }
5974
5975
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5976 {
5977 return qe_invalid;
5978 }
5979
5980
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5981 {
5982 return qe_invalid;
5983 }
5984
5985
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5986 {
5987 return qe_invalid;
5988 }
5989
5990
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5991 {
5992 return qe_invalid;
5993 }
5994
5995
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5996 {
5997 return qe_invalid;
5998 }
5999
6000
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
6001 {
6002 return qe_invalid;
6003 }
6004
6005
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6006 {
6007 return qe_invalid;
6008 }
6009
6010
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6011 {
6012 return qe_invalid;
6013 }
6014
6015
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6016 {
6017 return qe_invalid;
6018 }
6019
6020
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6021 {
6022 return qe_invalid;
6023 }
6024
6025 83 temp_misc.colors.msgtext = 0x01;
6026
6027
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
6028 {
6029
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
6030 {
6031
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 if(!p_getc(&tempbyte,f))
6032 {
6033 return qe_invalid;
6034 }
6035 168 }
6036 24 }
6037
6038
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
6039 {
6040
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
6041 {
6042
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&tempbyte,f))
6043 {
6044 return qe_invalid;
6045 }
6046 1536 }
6047 6 }
6048
6049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(s_version>1)
6050 {
6051 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6052 {
6053 return qe_invalid;
6054 }
6055 }
6056
6057 //save game icons
6058
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
6059
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6060 {
6061 18 icons=3;
6062 18 }
6063
6064
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
6065 {
6066
2/4
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 314 times.
✗ Branch 3 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
6067 {
6068 return qe_invalid;
6069 }
6070 314 }
6071 83 }
6072
6073
3/4
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
838 if((Header->zelda_version < 0x192)||
6074
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 808 times.
814 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6075 {
6076
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 *Misc = temp_misc;
6077
6078 18 return 0;
6079 }
6080
6081 //pond information
6082
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 6 times.
814 if(Header->zelda_version < 0x193)
6083 {
6084
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6085 {
6086 pondsize=25;
6087 }
6088
6089
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6090 {
6091
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6092 {
6093
2/4
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6912 times.
✗ Branch 3 not taken.
6912 if(!p_getc(&tempbyte,f))
6094 {
6095 return qe_invalid;
6096
6097 }
6098 6912 }
6099 96 }
6100 6 }
6101
6102 //end string
6103 820 if((Header->zelda_version < 0x192)||
6104
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 808 times.
814 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6105 {
6106
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!p_getc(&tempbyte,f))
6107 {
6108 return qe_invalid;
6109 }
6110
6111 temp_misc.endstring=tempbyte;
6112
6113 if(!p_getc(&tempbyte,f))
6114 {
6115 return qe_invalid;
6116 }
6117 }
6118 else
6119 {
6120
3/4
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 814 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&temp_misc.endstring,f))
6121 {
6122 return qe_invalid;
6123 }
6124 }
6125
6126 //expansion
6127
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 6 times.
814 if(Header->zelda_version < 0x193)
6128 {
6129
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6130 {
6131 expansionsize=99*2;
6132 }
6133
6134
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6135 {
6136
2/4
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1176 times.
✗ Branch 3 not taken.
1176 if(!p_getc(&tempbyte,f))
6137 {
6138 return qe_invalid;
6139 }
6140 1176 }
6141 6 }
6142 //shops v8
6143
6144
6145
2/2
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 215 times.
814 if(s_version >= 8)
6146 {
6147
2/2
✓ Branch 0 taken 2528 times.
✓ Branch 1 taken 215 times.
2743 for(int32_t i=0; i<shops; i++)
6148 {
6149
2/2
✓ Branch 0 taken 7584 times.
✓ Branch 1 taken 2528 times.
10112 for(int32_t j=0; j<3; j++)
6150 {
6151
2/4
✓ Branch 0 taken 7584 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7584 times.
✗ Branch 3 not taken.
7584 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6152 return qe_invalid;
6153 7584 }
6154 2528 }
6155 215 }
6156
6157 814 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6158 814 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6159
6160 //v9 includes quest misc[32]
6161 // ... this has been deprecated (2024)
6162
2/2
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 215 times.
814 if(s_version >= 9)
6163 {
6164
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 6880 times.
7095 for ( int32_t q = 0; q < 32; q++ )
6165 {
6166
2/4
✓ Branch 0 taken 6880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6880 times.
✗ Branch 3 not taken.
6880 if(!p_igetl(&temp_misc.questmisc[q],f))
6167 return qe_invalid;
6168 6880 }
6169 // this was string labels
6170
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
215 if (pack_fseek(f, 32 * 128))
6171 return qe_invalid;
6172 215 }
6173
6174
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
814 if(s_version >= 11 )
6175 {
6176
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6177 return qe_invalid;
6178 215 }
6179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 599 times.
599 else if(s_version < 11 )
6180 {
6181 599 temp_misc.zscript_last_compiled_version = -1;
6182 599 }
6183
6184 814 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6185
6186
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
814 if(s_version >= 12)
6187 {
6188 byte spr;
6189
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t q = 0; q < sprMAX; ++q)
6190 {
6191
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(!p_getc(&spr,f))
6192 return qe_invalid;
6193 55040 temp_misc.sprites[q] = spr;
6194 55040 }
6195 215 }
6196 else
6197 {
6198 599 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6199 //temp_misc.sprites[sprFALL] = ;
6200 }
6201
6202
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
814 if(s_version >= 13)
6203 {
6204
2/2
✓ Branch 0 taken 13760 times.
✓ Branch 1 taken 215 times.
13975 for(size_t q = 0; q < 64; ++q)
6205 {
6206 13760 bottletype* bt = &(temp_misc.bottle_types[q]);
6207
2/4
✓ Branch 0 taken 13760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13760 times.
✗ Branch 3 not taken.
13760 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6208 return qe_invalid;
6209
2/2
✓ Branch 0 taken 13760 times.
✓ Branch 1 taken 41280 times.
55040 for(size_t j = 0; j < 3; ++j)
6210 {
6211
2/4
✓ Branch 0 taken 41280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41280 times.
✗ Branch 3 not taken.
41280 if (!p_getc(&(bt->counter[j]), f))
6212 return qe_invalid;
6213
2/4
✓ Branch 0 taken 41280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41280 times.
✗ Branch 3 not taken.
41280 if (!p_igetw(&(bt->amount[j]), f))
6214 return qe_invalid;
6215 41280 }
6216
2/4
✓ Branch 0 taken 13760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13760 times.
✗ Branch 3 not taken.
13760 if (!p_getc(&(bt->flags), f))
6217 return qe_invalid;
6218
2/4
✓ Branch 0 taken 13760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13760 times.
✗ Branch 3 not taken.
13760 if (!p_getc(&(bt->next_type), f))
6219 return qe_invalid;
6220 13760 }
6221
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(size_t q = 0; q < 256; ++q)
6222 {
6223 55040 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6224
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6225 return qe_invalid;
6226
2/2
✓ Branch 0 taken 165120 times.
✓ Branch 1 taken 55040 times.
220160 for(size_t j = 0; j < 3; ++j)
6227 {
6228
2/4
✓ Branch 0 taken 165120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165120 times.
✗ Branch 3 not taken.
165120 if (!p_getc(&(bst->fill[j]), f))
6229 return qe_invalid;
6230
2/4
✓ Branch 0 taken 165120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165120 times.
✗ Branch 3 not taken.
165120 if (!p_igetw(&(bst->comb[j]), f))
6231 return qe_invalid;
6232
2/4
✓ Branch 0 taken 165120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165120 times.
✗ Branch 3 not taken.
165120 if (!p_getc(&(bst->cset[j]), f))
6233 return qe_invalid;
6234
2/4
✓ Branch 0 taken 165120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165120 times.
✗ Branch 3 not taken.
165120 if (!p_igetw(&(bst->price[j]), f))
6235 return qe_invalid;
6236
2/4
✓ Branch 0 taken 165120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165120 times.
✗ Branch 3 not taken.
165120 if (!p_igetw(&(bst->str[j]), f))
6237 return qe_invalid;
6238 165120 }
6239 55040 }
6240 215 }
6241 else
6242 {
6243
2/2
✓ Branch 0 taken 38336 times.
✓ Branch 1 taken 599 times.
38935 for(size_t q = 0; q < 64; ++q)
6244
1/2
✓ Branch 0 taken 38336 times.
✗ Branch 1 not taken.
38336 temp_misc.bottle_types[q].clear();
6245
2/2
✓ Branch 0 taken 153344 times.
✓ Branch 1 taken 599 times.
153943 for(size_t q = 0; q < 256; ++q)
6246
1/2
✓ Branch 0 taken 153344 times.
✗ Branch 1 not taken.
153344 temp_misc.bottle_shop_types[q].clear();
6247 }
6248
6249
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
814 if(s_version >= 14)
6250 {
6251 byte msfx;
6252
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t q = 0; q < sfxMAX; ++q)
6253 {
6254
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(!p_getc(&msfx,f))
6255 return qe_invalid;
6256 55040 temp_misc.miscsfx[q] = msfx;
6257 55040 }
6258 215 }
6259 else
6260 {
6261 599 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6262 599 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6263 599 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6264 }
6265
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
814 if(s_version < 15)
6266 {
6267 599 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6268 599 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6269 599 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6270 599 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6271 599 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6272 599 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6273 599 }
6274
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 616 times.
814 if(s_version < 16)
6275 {
6276 616 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6277 616 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6278 616 }
6279
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 681 times.
814 if (s_version >= 17)
6280 {
6281 133 byte save_menu_count = 0;
6282
2/4
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 if (!p_getc(&save_menu_count, f))
6283 return qe_invalid;
6284
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 for(size_t q = 0; q < save_menu_count; ++q)
6285 {
6286 SaveMenu& menu = temp_misc.save_menus[q];
6287 menu.clear();
6288
6289 byte menu_empty;
6290 if (!p_getc(&menu_empty, f))
6291 return qe_invalid;
6292 if (menu_empty)
6293 continue;
6294
6295 if (!p_getcstr(&menu.name, f))
6296 return qe_invalid;
6297
6298 if (!p_igetw(&menu.flags, f))
6299 return qe_invalid;
6300
6301 if (!p_igetl(&menu.cursor_tile, f))
6302 return qe_invalid;
6303
6304 if (!p_getc(&menu.cursor_cset, f))
6305 return qe_invalid;
6306
6307 if (!p_getc(&menu.cursor_sfx, f))
6308 return qe_invalid;
6309
6310 if (!p_getc(&menu.choose_sfx, f))
6311 return qe_invalid;
6312
6313 if (!p_getc(&menu.bg_color, f))
6314 return qe_invalid;
6315
6316 if (!p_getc(&menu.hspace, f))
6317 return qe_invalid;
6318
6319 if (!p_getc(&menu.vspace, f))
6320 return qe_invalid;
6321
6322 if (!p_getc(&menu.opt_x, f))
6323 return qe_invalid;
6324
6325 if (!p_getc(&menu.opt_y, f))
6326 return qe_invalid;
6327
6328 if (!p_getc(&menu.text_align, f))
6329 return qe_invalid;
6330
6331 if (!p_getc(&menu.textbox_align, f))
6332 return qe_invalid;
6333
6334 if (!p_igetw(&menu.close_frames, f))
6335 return qe_invalid;
6336
6337 if (!p_getc(&menu.close_flash_rate, f))
6338 return qe_invalid;
6339
6340 if (s_version < 18)
6341 {
6342 int16_t midi;
6343 if (!p_igetw(&midi, f))
6344 return qe_invalid;
6345 if (should_skip)
6346 menu.music = 0;
6347 else menu.music = find_or_make_midi_music(convert_from_old_midi_id(midi));
6348 }
6349 else if (!p_igetw(&menu.music, f))
6350 return qe_invalid;
6351
6352 if (!p_igetl(&menu.bg_tile, f))
6353 return qe_invalid;
6354
6355 if (!p_getc(&menu.bg_cset, f))
6356 return qe_invalid;
6357
6358 if (!p_getc(&menu.bg_tw, f))
6359 return qe_invalid;
6360
6361 if (!p_getc(&menu.bg_th, f))
6362 return qe_invalid;
6363
6364 byte opt_count;
6365 if (!p_getc(&opt_count, f))
6366 return qe_invalid;
6367 menu.options.resize(opt_count);
6368
6369 for (size_t q = 0; q < opt_count; ++q)
6370 {
6371 SaveMenuOption& opt = menu.options[q];
6372
6373 if (!p_getcstr(&opt.text, f))
6374 return qe_invalid;
6375
6376 if (!p_igetw(&opt.flags, f))
6377 return qe_invalid;
6378
6379 if (!p_getc(&opt.color, f))
6380 return qe_invalid;
6381
6382 if (!p_getc(&opt.picked_color, f))
6383 return qe_invalid;
6384
6385 if (!p_igetl(&opt.font, f))
6386 return qe_invalid;
6387
6388 if (!p_igetw(&opt.gen_script, f))
6389 return qe_invalid;
6390 }
6391 }
6392
6393
2/4
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 if (!p_getc(&temp_misc.savemenu_game_over, f))
6394 return qe_invalid;
6395
2/4
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 if (!p_getc(&temp_misc.savemenu_f6, f))
6396 return qe_invalid;
6397 133 }
6398
6399
2/2
✓ Branch 0 taken 813 times.
✓ Branch 1 taken 1 times.
814 if (!should_skip)
6400
1/2
✓ Branch 0 taken 813 times.
✗ Branch 1 not taken.
813 *Misc = temp_misc;
6401
6402 814 return 0;
6403 2008 }
6404
6405 extern char *item_string[MAXITEMS];
6406 extern const char *old_item_string[iLast];
6407 extern char *weapon_string[MAXWPNS];
6408 extern const char *old_weapon_string[wLast];
6409
6410 498 int32_t readitems(PACKFILE *f, word version, word build)
6411 {
6412
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6413
6414 byte padding;
6415 int32_t dummy;
6416 498 word items_to_read=MAXITEMS;
6417 498 itemdata tempitem;
6418 498 word s_version=0;
6419 word dummy_word;
6420
6421
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 6 times.
498 if(version < 0x186)
6422 {
6423 6 items_to_read=64;
6424 6 }
6425
6426
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 474 times.
498 if(version > 0x192)
6427 {
6428 474 items_to_read=0;
6429
6430 //section version info
6431
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&s_version,f))
6432 {
6433 return qe_invalid;
6434 }
6435
6436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (s_version > V_ITEMS)
6437 return qe_version;
6438
6439 474 FFCore.quest_format[vItems] = s_version;
6440
6441
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!read_deprecated_section_cversion(f))
6442 {
6443 return qe_invalid;
6444 }
6445
6446 //section size
6447
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
6448 {
6449 return qe_invalid;
6450 }
6451
6452 //finally... section data
6453
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&items_to_read,f))
6454 {
6455 return qe_invalid;
6456 }
6457
6458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (items_to_read > MAXITEMS)
6459 {
6460 return qe_invalid;
6461 }
6462 474 }
6463
6464
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 83 times.
498 if(s_version>1)
6465 {
6466
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i=0; i<items_to_read; i++)
6467 {
6468 char tempname[64];
6469
6470
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!pfread(tempname, 64, f))
6471 {
6472 return qe_invalid;
6473 }
6474
6475 106240 item_string[i][0] = '\0';
6476 106240 strncat(item_string[i], tempname, 64 - 1);
6477 106240 }
6478 415 }
6479
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6480 {
6481
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6482 {
6483 20992 reset_itemname(i);
6484 20992 }
6485 82 }
6486
6487
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 497 times.
498 if (!should_skip)
6488
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<MAXITEMS; i++)
6489 {
6490 127232 itemdata& id = itemsbuf[i];
6491 127232 memset(&id, 0, sizeof(itemdata));
6492 127232 id.count=-1;
6493 127232 id.playsound=WAV_SCALE;
6494 127232 reset_itembuf(&id,i);
6495 127729 }
6496
6497
2/2
✓ Branch 0 taken 115362 times.
✓ Branch 1 taken 498 times.
115860 for(int32_t i=0; i<items_to_read; i++)
6498 {
6499 115362 tempitem = itemdata();
6500 115362 reset_itembuf(&tempitem,i);
6501
6502
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 60322 times.
115362 if ( s_version > 35 ) //expanded tiles
6503 {
6504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.tile,f))
6505 {
6506 return qe_invalid;
6507 }
6508 55040 }
6509 else
6510 {
6511
1/2
✓ Branch 0 taken 60322 times.
✗ Branch 1 not taken.
60322 if(!p_igetw(&tempitem.tile,f))
6512 {
6513 return qe_invalid;
6514 }
6515 }
6516
6517
1/2
✓ Branch 0 taken 115362 times.
✗ Branch 1 not taken.
115362 if(!p_getc(&tempitem.misc_flags,f))
6518 {
6519 return qe_invalid;
6520 }
6521
6522
1/2
✓ Branch 0 taken 115362 times.
✗ Branch 1 not taken.
115362 if(!p_getc(&tempitem.csets,f))
6523 {
6524 return qe_invalid;
6525 }
6526
6527
1/2
✓ Branch 0 taken 115362 times.
✗ Branch 1 not taken.
115362 if(!p_getc(&tempitem.frames,f))
6528 {
6529 return qe_invalid;
6530 }
6531
6532
1/2
✓ Branch 0 taken 115362 times.
✗ Branch 1 not taken.
115362 if(!p_getc(&tempitem.speed,f))
6533 {
6534 return qe_invalid;
6535 }
6536
6537
1/2
✓ Branch 0 taken 115362 times.
✗ Branch 1 not taken.
115362 if(!p_getc(&tempitem.delay,f))
6538 {
6539 return qe_invalid;
6540 }
6541
6542
2/2
✓ Branch 0 taken 110370 times.
✓ Branch 1 taken 4992 times.
115362 if(version < 0x193)
6543 {
6544
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6545 {
6546 return qe_invalid;
6547 }
6548
6549
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6550 {
6551
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6552 256 continue;
6553
6554
3/3
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 4690 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6555 {
6556 case iShield:
6557 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6558 23 break;
6559
6560 case iMShield:
6561 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6562 23 break;
6563
6564 default:
6565 4690 tempitem.ltm=0;
6566 4690 break;
6567 }
6568
6569 4736 tempitem.count=-1;
6570 4736 tempitem.flags=item_none;
6571 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6572 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6573 4736 tempitem.type=0xFF;
6574 4736 tempitem.playsound=WAV_SCALE;
6575 4736 reset_itembuf(&tempitem,i);
6576
6577 4736 itemsbuf[i] = tempitem;
6578
6579 4736 continue;
6580 }
6581 }
6582
6583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110370 times.
110370 if(!p_igetl(&tempitem.ltm,f))
6584 {
6585 return qe_invalid;
6586 }
6587
6588
1/2
✓ Branch 0 taken 110370 times.
✗ Branch 1 not taken.
110370 if(version < 0x193)
6589 {
6590 for(int32_t q=0; q<12; q++)
6591 {
6592 if(!p_getc(&padding,f))
6593 {
6594 return qe_invalid;
6595 }
6596 }
6597 }
6598
6599
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 4130 times.
110370 if(s_version>1)
6600 {
6601
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 51200 times.
106240 if ( s_version >= 31 )
6602 {
6603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.type,f))
6604 {
6605 return qe_invalid;
6606 }
6607 55040 }
6608 else
6609 {
6610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.type,f))
6611 {
6612 return qe_invalid;
6613 }
6614 }
6615
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version < 16)
6616 if(tempitem.type == 0xFF)
6617 tempitem.type = itype_misc;
6618
6619
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.level,f))
6620 {
6621 return qe_invalid;
6622 }
6623
6624
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version>5)
6625 {
6626
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 51200 times.
106240 if(s_version>=31)
6627 {
6628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.power,f))
6629 {
6630 return qe_invalid;
6631 }
6632 55040 }
6633 else
6634 {
6635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.power,f))
6636 {
6637 return qe_invalid;
6638 }
6639 }
6640
6641 //converted flags from 16b to 32b -Z
6642
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version < 41 )
6643 {
6644
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&tempitem.flags,f))
6645 {
6646 return qe_invalid;
6647 }
6648 51200 }
6649 else
6650 {
6651
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.flags,f))
6652 {
6653 return qe_invalid;
6654 }
6655 }
6656 106240 }
6657 else
6658 {
6659 //tempitem.power = tempitem.fam_type;
6660 char tempchar;
6661
6662 if(!p_getc(&tempchar,f))
6663 {
6664 return qe_invalid;
6665 }
6666
6667 if (tempchar) tempitem.flags |= item_gamedata;
6668 }
6669
6670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetw(&tempitem.script,f))
6671 {
6672 return qe_invalid;
6673 }
6674
6675
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version<=3)
6676 {
6677 if(tempitem.script > NUMSCRIPTITEM)
6678 {
6679 tempitem.script = 0;
6680 }
6681 }
6682
6683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.count,f))
6684 {
6685 return qe_invalid;
6686 }
6687
6688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetw(&tempitem.amount,f))
6689 {
6690 return qe_invalid;
6691 }
6692
6693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetw(&tempitem.collect_script,f))
6694 {
6695 return qe_invalid;
6696 }
6697
6698
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version<=3)
6699 {
6700 if(tempitem.collect_script > NUMSCRIPTITEM)
6701 {
6702 tempitem.collect_script = 0;
6703 }
6704 }
6705
6706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetw(&tempitem.setmax,f))
6707 {
6708 return qe_invalid;
6709 }
6710
6711
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetw(&tempitem.max,f))
6712 {
6713 return qe_invalid;
6714 }
6715
6716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.playsound,f))
6717 {
6718 return qe_invalid;
6719 }
6720
6721
2/2
✓ Branch 0 taken 849920 times.
✓ Branch 1 taken 106240 times.
956160 for(int32_t j=0; j<8; j++)
6722 {
6723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 849920 times.
849920 if(!p_igetl(&tempitem.initiald[j],f))
6724 {
6725 return qe_invalid;
6726 }
6727 849920 }
6728
6729
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 106240 times.
318720 for(int32_t j=0; j<2; j++)
6730 {
6731 byte temp;
6732
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&temp,f))
6733 {
6734 return qe_invalid;
6735 }
6736 212480 }
6737
6738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(s_version>4)
6739 {
6740
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version>5)
6741 {
6742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.wpn,f))
6743 {
6744 return qe_invalid;
6745 }
6746
6747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.wpn2,f))
6748 {
6749 return qe_invalid;
6750 }
6751
6752
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.wpn3,f))
6753 {
6754 return qe_invalid;
6755 }
6756
6757
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.wpn4,f))
6758 {
6759 return qe_invalid;
6760 }
6761
6762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(s_version>=15)
6763 {
6764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.wpn5,f))
6765 {
6766 return qe_invalid;
6767 }
6768
6769
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.wpn6,f))
6770 {
6771 return qe_invalid;
6772 }
6773
6774
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.wpn7,f))
6775 {
6776 return qe_invalid;
6777 }
6778
6779
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.wpn8,f))
6780 {
6781 return qe_invalid;
6782 }
6783
6784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.wpn9,f))
6785 {
6786 return qe_invalid;
6787 }
6788
6789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_getc(&tempitem.wpn10,f))
6790 {
6791 return qe_invalid;
6792 }
6793 106240 }
6794
6795
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.pickup_hearts,f))
6796 {
6797 return qe_invalid;
6798 }
6799
6800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(s_version<15)
6801 {
6802 if(!p_igetw(&dummy_word,f))
6803 {
6804 return qe_invalid;
6805 }
6806
6807 tempitem.misc1=dummy_word;
6808
6809 if(!p_igetw(&dummy_word,f))
6810 {
6811 return qe_invalid;
6812 }
6813
6814 tempitem.misc2=dummy_word;
6815 }
6816 else
6817 {
6818
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc1,f))
6819 {
6820 return qe_invalid;
6821 }
6822
6823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetl(&tempitem.misc2,f))
6824 {
6825 return qe_invalid;
6826 }
6827
6828 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6829
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(s_version<24)
6830 {
6831 if(tempitem.type==itype_shield)
6832 {
6833 tempitem.misc1|=sh_script;
6834 }
6835 }
6836 }
6837
6838
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if(s_version < 53)
6839 {
6840 byte tempbyte;
6841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempbyte,f))
6842 {
6843 return qe_invalid;
6844 }
6845 51200 tempitem.cost_amount[0] = tempbyte;
6846 51200 }
6847 else
6848 {
6849
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 55040 times.
165120 for(auto q = 0; q < 2; ++q)
6850 {
6851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110080 times.
110080 if(!p_igetw(&tempitem.cost_amount[q],f))
6852 {
6853 return qe_invalid;
6854 }
6855 110080 }
6856 }
6857 106240 }
6858 else
6859 {
6860 char tempchar;
6861
6862 if(!p_getc(&tempchar,f))
6863 {
6864 return qe_invalid;
6865 }
6866
6867 if (tempchar) tempitem.flags |= item_edible;
6868 }
6869
6870 // June 2007: more misc. attributes
6871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(s_version>=12)
6872 {
6873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(s_version<15)
6874 {
6875 if(!p_igetw(&dummy_word,f))
6876 {
6877 return qe_invalid;
6878 }
6879
6880 tempitem.misc3=dummy_word;
6881
6882 if(!p_igetw(&dummy_word,f))
6883 {
6884 return qe_invalid;
6885 }
6886
6887 tempitem.misc4=dummy_word;
6888 }
6889 else
6890 {
6891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetl(&tempitem.misc3,f))
6892 {
6893 return qe_invalid;
6894 }
6895
6896
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc4,f))
6897 {
6898 return qe_invalid;
6899 }
6900
6901
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc5,f))
6902 {
6903 return qe_invalid;
6904 }
6905
6906
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc6,f))
6907 {
6908 return qe_invalid;
6909 }
6910
6911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetl(&tempitem.misc7,f))
6912 {
6913 return qe_invalid;
6914 }
6915
6916
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc8,f))
6917 {
6918 return qe_invalid;
6919 }
6920
6921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106240 times.
106240 if(!p_igetl(&tempitem.misc9,f))
6922 {
6923 return qe_invalid;
6924 }
6925
6926
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_igetl(&tempitem.misc10,f))
6927 {
6928 return qe_invalid;
6929 }
6930 }
6931
6932
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!p_getc(&tempitem.usesound,f))
6933 {
6934 return qe_invalid;
6935 }
6936
6937
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 51200 times.
106240 if(s_version >= 49)
6938 {
6939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_getc(&tempitem.usesound2,f))
6940 {
6941 return qe_invalid;
6942 }
6943 55040 }
6944 51200 else tempitem.usesound2 = 0;
6945
6946
3/4
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
✓ Branch 2 taken 51200 times.
✗ Branch 3 not taken.
106240 if(s_version < 50 && tempitem.type == itype_mirror)
6947 {
6948 //Split continue/dmap warp effect/sfx, port for old
6949 tempitem.misc2 = tempitem.misc1;
6950 tempitem.usesound2 = tempitem.usesound;
6951 }
6952 106240 }
6953 106240 }
6954
6955
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6956 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6957
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 13312 times.
55040 if(s_version < 63)
6958 {
6959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13312 times.
13312 if(!p_getc(&tempitem.weap_data.imitate_weapon,f))
6960 {
6961 return qe_invalid;
6962 }
6963
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_getc(&tempitem.weap_data.default_defense,f))
6964 {
6965 return qe_invalid;
6966 }
6967 13312 }
6968
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.weaprange,f))
6969 {
6970 return qe_invalid;
6971 }
6972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.weapduration,f))
6973 {
6974 return qe_invalid;
6975 }
6976
2/2
✓ Branch 0 taken 550400 times.
✓ Branch 1 taken 55040 times.
605440 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6977 {
6978
1/2
✓ Branch 0 taken 550400 times.
✗ Branch 1 not taken.
550400 if(!p_igetl(&tempitem.weap_pattern[q],f))
6979 {
6980 return qe_invalid;
6981 }
6982 550400 }
6983 55040 }
6984
6985
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6986 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.duplicates,f))
6988 {
6989 return qe_invalid;
6990 }
6991
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 13312 times.
55040 if(s_version < 63)
6992
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 13312 times.
119808 for ( int32_t q = 0; q < INITIAL_D; q++ )
6993
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&tempitem.weap_data.initd[q],f))
6994 13312 return qe_invalid;
6995
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 55040 times.
165120 for ( int32_t q = 0; q < 2; q++ )
6996 {
6997 byte temp;
6998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110080 times.
110080 if(!p_getc(&temp,f))
6999 {
7000 return qe_invalid;
7001 }
7002 110080 }
7003
7004
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_getc(&tempitem.drawlayer,f))
7005 {
7006 return qe_invalid;
7007 }
7008
7009
7010
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.hxofs,f))
7011 {
7012 return qe_invalid;
7013 }
7014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.hyofs,f))
7015 {
7016 return qe_invalid;
7017 }
7018
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.hxsz,f))
7019 {
7020 return qe_invalid;
7021 }
7022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.hysz,f))
7023 {
7024 return qe_invalid;
7025 }
7026
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.hzsz,f))
7027 {
7028 return qe_invalid;
7029 }
7030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.xofs,f))
7031 {
7032 return qe_invalid;
7033 }
7034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.yofs,f))
7035 {
7036 return qe_invalid;
7037 }
7038
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 13312 times.
55040 if(s_version < 63)
7039 {
7040
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.hxofs,f))
7041 return qe_invalid;
7042
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.hyofs,f))
7043 return qe_invalid;
7044
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.hxsz,f))
7045 return qe_invalid;
7046
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.hysz,f))
7047 return qe_invalid;
7048
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.hzsz,f))
7049 return qe_invalid;
7050
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.xofs,f))
7051 return qe_invalid;
7052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13312 times.
13312 if(!p_igetl(&tempitem.weap_data.yofs,f))
7053 return qe_invalid;
7054 13312 }
7055
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 13312 times.
55040 if(s_version < 63)
7056
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetw(&tempitem.weap_data.script,f))
7057 return qe_invalid;
7058
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.wpnsprite,f))
7059 {
7060 return qe_invalid;
7061 }
7062 55040 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
7063
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 55040 times.
165120 for(auto q = 0; q < num_cost_tmr; ++q)
7064 {
7065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110080 times.
110080 if(!p_igetl(&tempitem.magiccosttimer[q],f))
7066 {
7067 return qe_invalid;
7068 }
7069 110080 }
7070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 for(auto q = num_cost_tmr; q < 2; ++q)
7071 tempitem.magiccosttimer[q] = 0;
7072 55040 }
7073
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7074 {
7075 //Item Size FLags, TileWidth, TileHeight
7076
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.overrideFLAGS,f))
7077 {
7078 return qe_invalid;
7079 }
7080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.tilew,f))
7081 {
7082 return qe_invalid;
7083 }
7084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_igetl(&tempitem.tileh,f))
7085 {
7086 return qe_invalid;
7087 }
7088 55040 }
7089
4/4
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 51200 times.
✓ Branch 2 taken 41728 times.
✓ Branch 3 taken 13312 times.
106240 if ( s_version >= 29 && s_version < 63) //! More new vars.
7090 {
7091
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.override_flags,f))
7092 return qe_invalid;
7093
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.tilew,f))
7094 return qe_invalid;
7095
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if(!p_igetl(&tempitem.weap_data.tileh,f))
7096 return qe_invalid;
7097 13312 }
7098
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 30 ) //! More new vars.
7099 {
7100 //Pickup Type
7101
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempitem.pickup,f))
7102 {
7103 return qe_invalid;
7104 }
7105 55040 }
7106
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 32 ) //! More new vars.
7107 {
7108 //Pickup Type
7109
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetw(&tempitem.pstring,f))
7110 {
7111 return qe_invalid;
7112 }
7113 55040 }
7114
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 33 ) //! More new vars.
7115 {
7116 //Pickup Type
7117
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetw(&tempitem.pickup_string_flags,f))
7118 {
7119 return qe_invalid;
7120 }
7121 55040 }
7122
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 34 ) //! cost counter
7123 {
7124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(s_version < 53)
7125 {
7126 if(!p_getc(&tempitem.cost_counter[0],f))
7127 {
7128 return qe_invalid;
7129 }
7130 }
7131 else
7132 {
7133
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 55040 times.
165120 for(auto q = 0; q < 2; ++q)
7134 {
7135
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_getc(&tempitem.cost_counter[q],f))
7136 {
7137 return qe_invalid;
7138 }
7139 110080 }
7140 }
7141 55040 }
7142
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 44 ) //! sprite scripts
7143 {
7144
2/2
✓ Branch 0 taken 440320 times.
✓ Branch 1 taken 55040 times.
495360 for ( int32_t q = 0; q < 8; q++ )
7145 {
7146
2/2
✓ Branch 0 taken 28620800 times.
✓ Branch 1 taken 440320 times.
29061120 for ( int32_t w = 0; w < 65; w++ )
7147 {
7148
1/2
✓ Branch 0 taken 28620800 times.
✗ Branch 1 not taken.
28620800 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7149 {
7150 return qe_invalid;
7151 }
7152 28620800 }
7153
2/2
✓ Branch 0 taken 333824 times.
✓ Branch 1 taken 106496 times.
440320 if(s_version < 63)
7154
2/2
✓ Branch 0 taken 6922240 times.
✓ Branch 1 taken 106496 times.
7028736 for ( int32_t w = 0; w < 65; w++ )
7155
1/2
✓ Branch 0 taken 6922240 times.
✗ Branch 1 not taken.
6922240 if(!p_getc(&padding,f))
7156 106496 return qe_invalid;
7157
2/2
✓ Branch 0 taken 28620800 times.
✓ Branch 1 taken 440320 times.
29061120 for ( int32_t w = 0; w < 65; w++ )
7158 {
7159
1/2
✓ Branch 0 taken 28620800 times.
✗ Branch 1 not taken.
28620800 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7160 {
7161 return qe_invalid;
7162 }
7163 28620800 }
7164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 440320 times.
440320 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7165 {
7166 return qe_invalid;
7167 }
7168
7169 440320 }
7170
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 55040 times.
165120 for ( int32_t q = 0; q < 2; q++ )
7171 {
7172 byte temp;
7173
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_getc(&temp,f))
7174 {
7175 return qe_invalid;
7176 }
7177 110080 }
7178 //Pickup Type
7179
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetw(&tempitem.sprite_script,f))
7180 {
7181 return qe_invalid;
7182 }
7183 55040 }
7184
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 55040 times.
106240 if ( s_version >= 48 ) //! pickup flags
7185 {
7186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(!p_getc(&(tempitem.pickupflag),f))
7187 {
7188 return qe_invalid;
7189 }
7190 55040 }
7191
2/2
✓ Branch 0 taken 54528 times.
✓ Branch 1 taken 51712 times.
106240 if ( s_version >= 57 )
7192 {
7193 51712 std::string str;
7194
2/4
✓ Branch 0 taken 51712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51712 times.
✗ Branch 3 not taken.
51712 if(!p_getcstr(&str,f))
7195 return qe_invalid;
7196 51712 strncpy(tempitem.display_name,str.c_str(),255);
7197
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 51712 times.
51712 }
7198 106240 }
7199 else
7200 {
7201 4130 tempitem.count=-1;
7202 4130 tempitem.type=itype_misc;
7203 4130 tempitem.flags=item_none;
7204 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7205 4130 tempitem.playsound=WAV_SCALE;
7206 4130 reset_itembuf(&tempitem,i);
7207 }
7208
7209
4/4
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 59682 times.
✓ Branch 2 taken 41728 times.
✓ Branch 3 taken 8960 times.
110370 if(s_version >= 58 && s_version < 63)
7210 {
7211
2/2
✓ Branch 0 taken 44800 times.
✓ Branch 1 taken 8960 times.
53760 for(int q = 0; q < WPNSPR_MAX; ++q)
7212 {
7213
1/2
✓ Branch 0 taken 44800 times.
✗ Branch 1 not taken.
44800 if(!p_getc(&tempitem.weap_data.burnsprs[q],f))
7214 return qe_invalid;
7215
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 43520 times.
44800 if(s_version >= 59)
7216
1/2
✓ Branch 0 taken 43520 times.
✗ Branch 1 not taken.
43520 if(!p_getc(&tempitem.weap_data.light_rads[q],f))
7217 return qe_invalid;
7218 44800 }
7219 8960 }
7220
7221
2/2
✓ Branch 0 taken 67106 times.
✓ Branch 1 taken 43264 times.
110370 if ( s_version >= 60 )
7222 {
7223
2/2
✓ Branch 0 taken 39168 times.
✓ Branch 1 taken 4096 times.
43264 if ( s_version >= 65 )
7224 {
7225
1/2
✓ Branch 0 taken 39168 times.
✗ Branch 1 not taken.
39168 if(!p_igetw(&tempitem.pickup_litems,f))
7226 return qe_invalid;
7227 39168 }
7228 else
7229 {
7230
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_getc(&padding,f))
7231 return qe_invalid;
7232 4096 tempitem.pickup_litems = word(padding);
7233 }
7234
1/2
✓ Branch 0 taken 43264 times.
✗ Branch 1 not taken.
43264 if(!p_igetw(&tempitem.pickup_litem_level,f))
7235 return qe_invalid;
7236 43264 }
7237
7238
2/2
✓ Branch 0 taken 43264 times.
✓ Branch 1 taken 67106 times.
110370 if ( s_version >= 62 )
7239 {
7240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43264 times.
43264 if (!p_igetl(&tempitem.moveflags, f))
7241 return qe_invalid;
7242
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 1536 times.
43264 if(s_version < 63)
7243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if (!p_igetl(&tempitem.weap_data.moveflags, f))
7244 return qe_invalid;
7245 43264 }
7246 else
7247 {
7248 67106 tempitem.moveflags = (move_obeys_grav | move_can_pitfall);
7249
3/3
✓ Branch 0 taken 1932 times.
✓ Branch 1 taken 64872 times.
✓ Branch 2 taken 302 times.
67106 switch(tempitem.type)
7250 {
7251 case itype_divinefire:
7252
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 135 times.
302 if(!(tempitem.flags & item_flag3))
7253 135 break;
7254 [[fallthrough]];
7255 case itype_bomb: case itype_sbomb:
7256 case itype_bait: case itype_liftglove:
7257 case itype_candle: case itype_book:
7258 2099 tempitem.weap_data.moveflags = (move_obeys_grav | move_can_pitfall);
7259 2099 break;
7260 default:
7261 64872 tempitem.weap_data.moveflags = move_none;
7262 64872 break;
7263 }
7264 }
7265
7266
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 68642 times.
110370 if(s_version >= 63)
7267 {
7268
1/2
✓ Branch 0 taken 41728 times.
✗ Branch 1 not taken.
41728 if(auto ret = read_weap_data(tempitem.weap_data, f))
7269 return ret;
7270 41728 }
7271 else
7272 {
7273
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 68624 times.
68642 SETFLAG(tempitem.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempitem.flags & item_burning_sprites);
7274
3/3
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 67944 times.
✓ Branch 2 taken 66 times.
68642 switch(tempitem.type)
7275 {
7276 case itype_liftglove:
7277 66 tempitem.weap_data.wflags = WFLAG_BREAK_WHEN_LANDING;
7278 66 break;
7279 case itype_bomb: case itype_sbomb:
7280 // Moving these over and removing them from itemdata
7281
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 24 times.
632 if(tempitem.flags & item_flag3)
7282 24 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_LANDING;
7283
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 24 times.
632 if(tempitem.flags & item_flag5)
7284 24 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_HIT_SOLID;
7285 632 tempitem.flags &= ~(item_flag3|item_flag5);
7286
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 18 times.
632 if(tempitem.misc4)
7287 {
7288 18 tempitem.weap_data.lift_level = tempitem.misc4;
7289 18 tempitem.weap_data.lift_time = tempitem.misc5;
7290 18 tempitem.weap_data.lift_height = tempitem.misc6;
7291 18 tempitem.misc4 = 0;
7292 18 tempitem.misc5 = 0;
7293 18 tempitem.misc6 = 0;
7294 18 }
7295 632 break;
7296 }
7297 }
7298
7299
2/2
✓ Branch 0 taken 71202 times.
✓ Branch 1 taken 39168 times.
110370 if (s_version >= 64)
7300 {
7301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39168 times.
39168 if (!p_igetl(&tempitem.cooldown, f))
7302 return qe_invalid;
7303 39168 }
7304
7305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110370 times.
110370 if (!should_skip)
7306 {
7307
1/2
✓ Branch 0 taken 110370 times.
✗ Branch 1 not taken.
110370 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7308 {
7309 tempitem.script = 0;
7310 tempitem.weap_data.script = 0;
7311 for(int q = 0; q < 8; ++q)
7312 {
7313 tempitem.initiald[q] = 0;
7314 tempitem.weap_data.initd[q] = 0;
7315 }
7316 }
7317 110370 itemsbuf[i] = tempitem;
7318 110370 }
7319 110370 }
7320
7321
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 497 times.
498 if (should_skip)
7322 1 return 0;
7323
7324 //////////////////////////////////////////////////////
7325 // Now do any updates because of new item additions
7326 // (These can't be done above because items_to_read
7327 // might be too low.)
7328 //////////////////////////////////////////////////////
7329
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<MAXITEMS; i++)
7330 {
7331 127232 tempitem = itemsbuf[i];
7332
7333 //Account for older quests that didn't have an actual item for the used letter
7334
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 106240 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
127232 if(s_version < 2 && i==iLetterUsed)
7335 {
7336 82 reset_itembuf(&tempitem, iLetterUsed);
7337 82 strcpy(item_string[i],old_item_string[i]);
7338 82 tempitem.tile = itemsbuf[iLetter].tile;
7339 82 tempitem.csets = itemsbuf[iLetter].csets;
7340 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7341 82 tempitem.frames = itemsbuf[iLetter].frames;
7342 82 tempitem.speed = itemsbuf[iLetter].speed;
7343 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7344 82 }
7345
7346
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 3)
7347 {
7348
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7349 {
7350 case iRocsFeather:
7351 case iHoverBoots:
7352 case iSpinScroll:
7353 case iL2SpinScroll:
7354 case iCrossScroll:
7355 case iQuakeScroll:
7356 case iL2QuakeScroll:
7357 case iWhispRing:
7358 case iL2WhispRing:
7359 case iChargeRing:
7360 case iL2ChargeRing:
7361 case iPerilScroll:
7362 case iWalletL3:
7363 case iQuiverL4:
7364 case iBombBagL4:
7365 case iBracelet:
7366 case iL2Bracelet:
7367 case iOldGlove:
7368 case iL2Ladder:
7369 case iWealthMedal:
7370 case iL2WealthMedal:
7371 case iL3WealthMedal:
7372 1804 reset_itembuf(&tempitem, i);
7373 1804 strcpy(item_string[i],old_item_string[i]);
7374 1804 break;
7375
7376 case iSShield:
7377 82 reset_itembuf(&tempitem, i);
7378 82 strcpy(item_string[i],old_item_string[i]);
7379 82 strcpy(item_string[iShield],old_item_string[iShield]);
7380 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7381 82 break;
7382 }
7383 20992 }
7384
7385
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 5)
7386 {
7387
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7388 {
7389 case iHeartRing:
7390 case iL2HeartRing:
7391 case iL3HeartRing:
7392 case iMagicRing:
7393 case iL2MagicRing:
7394 case iL3MagicRing:
7395 case iL4MagicRing:
7396 574 reset_itembuf(&tempitem, i);
7397 574 strcpy(item_string[i],old_item_string[i]);
7398 574 break;
7399 }
7400 20992 }
7401
7402
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7403 {
7404
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7405
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7406
7407
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 328 times.
✓ Branch 11 taken 17302 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7408 {
7409 case iTriforce:
7410 82 tempitem.level=1;
7411 82 break;
7412
7413 case iBigTri:
7414 82 tempitem.level=0;
7415 82 break;
7416
7417 case iBombs:
7418 82 tempitem.level=i_bomb;
7419 82 tempitem.power=4;
7420 82 tempitem.wpn=wBOMB;
7421 82 tempitem.wpn2=wBOOM;
7422 82 tempitem.misc1 = 50;
7423
7424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7425
7426 82 break;
7427
7428 case iSBomb:
7429 82 tempitem.level=i_sbomb;
7430 82 tempitem.power=16;
7431 82 tempitem.wpn=wSBOMB;
7432 82 tempitem.wpn2=wSBOOM;
7433 82 tempitem.misc1 = 50;
7434
7435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7436
7437 82 break;
7438
7439 case iBook:
7440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7441 tempitem.wpn = wFIREMAGIC;
7442
7443 82 break;
7444
7445 case iSArrow:
7446 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7447 82 tempitem.power=4;
7448 82 tempitem.flags|=item_gamedata;
7449 82 tempitem.wpn=wSARROW;
7450 82 break;
7451
7452 case iGArrow:
7453 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7454 82 tempitem.power=8;
7455 82 tempitem.flags|=(item_gamedata|item_flag1);
7456 82 tempitem.wpn=wGARROW;
7457 82 break;
7458
7459 case iBrang:
7460 82 tempitem.power=0;
7461 82 tempitem.wpn=wBRANG;
7462 82 tempitem.misc1=36;
7463 82 break;
7464
7465 case iMBrang:
7466 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7467 82 tempitem.power=0;
7468 82 tempitem.wpn=wMBRANG;
7469 82 break;
7470
7471 case iFBrang:
7472 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7473 82 tempitem.power=2;
7474 82 tempitem.wpn=wFBRANG;
7475 82 break;
7476
7477 case iBoots:
7478 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7479 82 tempitem.power=7;
7480 82 break;
7481
7482 case iWand:
7483 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7484 82 tempitem.power=2;
7485 82 tempitem.wpn=wWAND;
7486 82 tempitem.wpn3=wMAGIC;
7487 82 break;
7488
7489 case iBCandle:
7490 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7491 82 tempitem.power=1;
7492 82 tempitem.flags|=(item_gamedata|item_flag1);
7493 82 tempitem.wpn3=wFIRE;
7494 82 break;
7495
7496 case iRCandle:
7497 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7498 82 tempitem.power=1;
7499 82 tempitem.wpn3=wFIRE;
7500 82 break;
7501
7502 case iSword:
7503 82 tempitem.power=1;
7504 82 tempitem.flags|= item_flag4 |item_flag2;
7505 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7506 82 tempitem.wpn2=wSWORDSLASH;
7507 82 break;
7508
7509 case iWSword:
7510 82 tempitem.power=2;
7511 82 tempitem.flags|= item_flag4 |item_flag2;
7512 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7513 82 tempitem.wpn2=wWSWORDSLASH;
7514 82 break;
7515
7516 case iMSword:
7517 82 tempitem.power=4;
7518 82 tempitem.flags|= item_flag4 |item_flag2;
7519 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7520 82 tempitem.wpn2=wMSWORDSLASH;
7521 82 break;
7522
7523 case iXSword:
7524 82 tempitem.power=8;
7525 82 tempitem.flags|= item_flag4 |item_flag2;
7526 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7527 82 tempitem.wpn2=wXSWORDSLASH;
7528 82 break;
7529
7530 case iDivineProtection:
7531 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7532 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7533 82 tempitem.wpn=wDIVINEPROTECTION1A;
7534 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7535 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7536 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7537 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7538 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7539 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7540 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7541 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7542 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7543 82 tempitem.misc1=512;
7544 82 tempitem.cost_amount[0]=64;
7545 82 break;
7546
7547 case iLens:
7548 82 tempitem.misc1=60;
7549 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7550 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7551 82 break;
7552
7553 case iArrow:
7554 82 tempitem.power=2;
7555 82 tempitem.wpn=wARROW;
7556 82 break;
7557
7558 case iHoverBoots:
7559 82 tempitem.misc1=45;
7560 82 tempitem.wpn=iwHover;
7561 82 break;
7562
7563 case iDivineFire:
7564 82 tempitem.power=8;
7565 82 tempitem.wpn=wDIVINEFIRE1A;
7566 82 tempitem.wpn2=wDIVINEFIRE1B;
7567 82 tempitem.wpn3=wDIVINEFIRES1A;
7568 82 tempitem.wpn4=wDIVINEFIRES1B;
7569 82 tempitem.misc1 = 32;
7570 82 tempitem.misc2 = 200;
7571 82 tempitem.cost_amount[0]=32;
7572 82 break;
7573
7574 case iDivineEscape:
7575 82 tempitem.cost_amount[0]=32;
7576 82 break;
7577
7578 case iHookshot:
7579 82 tempitem.power=0;
7580 82 tempitem.flags&=~item_flag1;
7581 82 tempitem.wpn=wHSHEAD;
7582 82 tempitem.wpn2=wHSCHAIN_H;
7583 82 tempitem.wpn4=wHSHANDLE;
7584 82 tempitem.wpn3=wHSCHAIN_V;
7585 82 tempitem.misc1=50;
7586 82 tempitem.misc2=100;
7587 82 break;
7588
7589 case iLongshot:
7590 82 tempitem.power=0;
7591 82 tempitem.flags&=~item_flag1;
7592 82 tempitem.wpn=wLSHEAD;
7593 82 tempitem.wpn2=wLSCHAIN_H;
7594 82 tempitem.wpn4=wLSHANDLE;
7595 82 tempitem.wpn3=wLSCHAIN_V;
7596 82 tempitem.misc1=99;
7597 82 tempitem.misc2=100;
7598 82 break;
7599
7600 case iHammer:
7601 82 tempitem.power=4;
7602 82 tempitem.wpn=wHAMMER;
7603 82 tempitem.wpn2=iwHammerSmack;
7604 82 break;
7605
7606 case iCByrna:
7607 82 tempitem.power=1;
7608 82 tempitem.wpn=wCBYRNA;
7609 82 tempitem.wpn2=wCBYRNASLASH;
7610 82 tempitem.wpn3=wCBYRNAORB;
7611 82 tempitem.misc1=4;
7612 82 tempitem.misc2=16;
7613 82 tempitem.misc3=1;
7614 82 tempitem.cost_amount[0]=1;
7615 82 break;
7616
7617 case iWhistle:
7618 82 tempitem.wpn=wWIND;
7619 82 tempitem.misc1=3;
7620 82 tempitem.flags|=item_flag1;
7621 82 break;
7622
7623 case iBRing:
7624 82 tempitem.power=2;
7625 82 tempitem.misc1=spBLUE;
7626 82 break;
7627
7628 case iRRing:
7629 82 tempitem.power=4;
7630 82 tempitem.misc1=spRED;
7631 82 break;
7632
7633 case iGRing:
7634 82 tempitem.power=8;
7635 82 tempitem.misc1=spGOLD;
7636 82 break;
7637
7638 case iSpinScroll:
7639 82 tempitem.power = 2;
7640 82 tempitem.misc1 = 1;
7641 82 break;
7642
7643 case iL2SpinScroll:
7644 82 tempitem.type=itype_spinscroll2;
7645 82 tempitem.level=1;
7646 82 tempitem.cost_amount[0]=8;
7647 82 tempitem.power=2;
7648 82 tempitem.misc1 = 20;
7649 82 break;
7650
7651 case iQuakeScroll:
7652 82 tempitem.misc1=0x10;
7653 82 tempitem.misc2=64;
7654 82 break;
7655
7656 case iL2QuakeScroll:
7657 82 tempitem.type=itype_quakescroll2;
7658 82 tempitem.level=1;
7659 82 tempitem.power = 2;
7660 82 tempitem.misc1=0x20;
7661 82 tempitem.misc2=192;
7662 82 tempitem.cost_amount[0]=8;
7663 82 break;
7664
7665 case iChargeRing:
7666 82 tempitem.misc1=64;
7667 82 tempitem.misc2=128;
7668 82 break;
7669
7670 case iL2ChargeRing:
7671 82 tempitem.misc1=32;
7672 82 tempitem.misc2=64;
7673 82 break;
7674
7675 case iOldGlove:
7676 82 tempitem.flags |= item_flag1;
7677
7678 //fallthrough
7679 case iBombBagL4:
7680 case iWalletL3:
7681 case iQuiverL4:
7682 case iBracelet:
7683 410 tempitem.power = 1;
7684 410 break;
7685
7686 case iL2Bracelet:
7687 82 tempitem.power = 2;
7688 82 break;
7689
7690 case iMKey:
7691 82 tempitem.power=0xFF;
7692 82 tempitem.flags |= item_flag1;
7693 82 break;
7694 }
7695 20992 }
7696
7697
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 7)
7698 {
7699
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7700 {
7701 case iStoneAgony:
7702 case iStompBoots:
7703 case iPerilRing:
7704 case iWhimsicalRing:
7705 {
7706 328 reset_itembuf(&tempitem, i);
7707 328 strcpy(item_string[i],old_item_string[i]);
7708 328 break;
7709 }
7710 }
7711 20992 }
7712
7713
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 8) // May 2007: Some corrections.
7714 {
7715
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7716 {
7717 case iMShield:
7718 82 tempitem.misc1|=sh_flame;
7719 82 tempitem.misc2|=sh_fireball|sh_magic;
7720
7721
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7722 {
7723 tempitem.misc2 |= sh_sword;
7724 }
7725
7726 // fallthrough
7727 case iShield:
7728 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7729
7730 // fallthrough
7731 case iSShield:
7732 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7733
7734
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7735 {
7736 tempitem.misc2 |= sh_rock;
7737 }
7738
7739 246 break;
7740
7741 case iWhispRing:
7742 82 tempitem.power=1;
7743 82 tempitem.flags|=item_gamedata|item_flag1;
7744 82 tempitem.misc1 = 3;
7745 82 break;
7746
7747 case iL2WhispRing:
7748 82 tempitem.power=0;
7749 82 tempitem.flags|=item_gamedata|item_flag1;
7750 82 tempitem.misc1 = 3;
7751 82 break;
7752
7753 case iL2Ladder:
7754 case iBow:
7755 case iCByrna:
7756 246 tempitem.power = 1;
7757 246 break;
7758 }
7759 20992 }
7760
7761
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 106240 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
127232 if(s_version < 9 && i==iClock)
7762 {
7763 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7764 82 }
7765
7766 //add the misc flag for bomb
7767
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 106240 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
127232 if(s_version < 10 && tempitem.type == itype_bomb)
7768 {
7769 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7770 82 }
7771
7772
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 106240 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
127232 if(s_version < 11 && tempitem.type == itype_triforcepiece)
7773 {
7774 164 tempitem.flags = (tempitem.level ? item_gamedata : item_none);
7775 164 tempitem.playsound = (tempitem.level ? WAV_SCALE : WAV_CLEARED);
7776 164 }
7777
7778
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 12) // June 2007: More Misc. attributes.
7779 {
7780
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7781 {
7782 case iFBrang:
7783 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7784
7785 //fallthrough
7786 case iMBrang:
7787 164 tempitem.misc3 |= sh_sword|sh_magic;
7788
7789 //fallthrough
7790 case iHookshot:
7791 case iLongshot:
7792 //fallthrough
7793 328 tempitem.misc3 |= sh_fireball;
7794
7795 case iBrang:
7796 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7797 410 break;
7798 }
7799
7800
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 164 times.
✓ Branch 5 taken 246 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 328 times.
✓ Branch 10 taken 164 times.
✓ Branch 11 taken 9629 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.type)
7801 {
7802 case itype_hoverboots:
7803 82 tempitem.usesound = WAV_ZN1HOVER;
7804 82 break;
7805
7806 case itype_wand:
7807 82 tempitem.usesound = WAV_WAND;
7808 82 break;
7809
7810 case itype_book:
7811 82 tempitem.usesound = WAV_FIRE;
7812 82 break;
7813
7814 case itype_arrow:
7815 246 tempitem.usesound = WAV_ARROW;
7816 246 break;
7817
7818 case itype_hookshot:
7819 164 tempitem.usesound = WAV_HOOKSHOT;
7820 164 break;
7821
7822 case itype_brang:
7823 246 tempitem.usesound = WAV_BRANG;
7824 246 break;
7825
7826 case itype_shield:
7827 246 tempitem.usesound = WAV_CHINK;
7828 246 break;
7829
7830 case itype_sword:
7831 9313 tempitem.usesound = WAV_SWORD;
7832 9313 break;
7833
7834 case itype_whistle:
7835 82 tempitem.usesound = WAV_WHISTLE;
7836 82 break;
7837
7838 case itype_hammer:
7839 82 tempitem.usesound = WAV_HAMMER;
7840 82 break;
7841
7842 case itype_divinefire:
7843 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7844 82 break;
7845
7846 case itype_divineescape:
7847 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7848 82 break;
7849
7850 case itype_divineprotection:
7851 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7852 82 break;
7853
7854 case itype_bomb:
7855 case itype_sbomb:
7856 case itype_quakescroll:
7857 case itype_quakescroll2:
7858 328 tempitem.usesound = WAV_BOMB;
7859 328 break;
7860
7861 case itype_spinscroll:
7862 case itype_spinscroll2:
7863 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7864 164 break;
7865 }
7866 20992 }
7867
7868
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 13) // July 2007
7869 {
7870
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7871 {
7872 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7873 82 tempitem.power = 1;
7874 82 tempitem.flags|=item_flag1;
7875 82 }
7876
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_wand)
7877 82 tempitem.flags|=item_flag1;
7878
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.type == itype_book)
7879 {
7880 82 tempitem.flags|=item_flag1;
7881 82 tempitem.power = 2;
7882 82 }
7883 20992 }
7884
7885
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 14) // August 2007
7886 {
7887
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.type == itype_fairy)
7888 {
7889 164 tempitem.usesound = WAV_SCALE;
7890
7891
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.level)
7892 164 tempitem.misc3=50;
7893 164 }
7894
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_potion)
7895 {
7896 164 tempitem.flags |= item_gain_old;
7897 164 }
7898 20992 }
7899
7900
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 17) // November 2007
7901 {
7902
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.type == itype_candle && !tempitem.wpn3)
7903 {
7904 tempitem.wpn3 = wFIRE;
7905 }
7906
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.type == itype_arrow && tempitem.power>4)
7907 {
7908 82 tempitem.flags|=item_flag1;
7909 82 }
7910 20992 }
7911
7912
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 18) // New Year's Eve 2007
7913 {
7914
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7915 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7916
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_bait)
7917 82 tempitem.misc1 = 768; // Frames until it goes
7918
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_triforcepiece)
7919 {
7920
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7921 {
7922 82 tempitem.misc2 = 1; // Cutscene 1
7923 82 tempitem.flags |= item_flag1; // Side Warp Out
7924 82 }
7925 164 }
7926 20992 }
7927
7928
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 19) // January 2008
7929 {
7930
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7931 {
7932
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7933
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7934 82 }
7935 20992 }
7936
7937
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 20) // October 2008
7938 {
7939
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7940 {
7941 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7942 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7943 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7944 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7945 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7946 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7947 82 }
7948 20992 }
7949
7950
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 21) // November 2008
7951 {
7952
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7953 {
7954 tempitem.flags &= ~item_unused;
7955
7956 if(tempitem.type == itype_sword ||
7957 tempitem.type == itype_wand ||
7958 tempitem.type == itype_candle ||
7959 tempitem.type == itype_cbyrna)
7960 {
7961 tempitem.flags |= item_flag4;
7962 }
7963 }
7964 20992 }
7965
7966
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 22) // September 2009
7967 {
7968
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.type == itype_sbomb || tempitem.type == itype_bomb)
7969 {
7970 164 tempitem.misc3 = tempitem.power/2;
7971 164 }
7972 20992 }
7973
7974
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 23) // March 2011
7975 {
7976
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_divinefire)
7977 82 tempitem.wpn5 = wFIRE;
7978
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.type == itype_book)
7979 82 tempitem.wpn2 = wFIRE;
7980 20992 }
7981
7982 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7983 // whether it was or not, and a lot of existing quests depended on the
7984 // incorrect behavior.
7985
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 20992 times.
127232 if(s_version < 25) // January 2012
7986 {
7987
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.type == itype_bombbag)
7988 328 tempitem.flags |= item_flag1;
7989
7990
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divinefire)
7991 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7992 20992 }
7993
7994
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7995 {
7996
60/60
✓ Branch 0 taken 17547 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 327 times.
✓ Branch 5 taken 282 times.
✓ Branch 6 taken 558 times.
✓ Branch 7 taken 614 times.
✓ Branch 8 taken 297 times.
✓ Branch 9 taken 917 times.
✓ Branch 10 taken 892 times.
✓ Branch 11 taken 557 times.
✓ Branch 12 taken 858 times.
✓ Branch 13 taken 558 times.
✓ Branch 14 taken 279 times.
✓ Branch 15 taken 558 times.
✓ Branch 16 taken 295 times.
✓ Branch 17 taken 279 times.
✓ Branch 18 taken 846 times.
✓ Branch 19 taken 282 times.
✓ Branch 20 taken 285 times.
✓ Branch 21 taken 560 times.
✓ Branch 22 taken 255 times.
✓ Branch 23 taken 282 times.
✓ Branch 24 taken 279 times.
✓ Branch 25 taken 279 times.
✓ Branch 26 taken 279 times.
✓ Branch 27 taken 295 times.
✓ Branch 28 taken 281 times.
✓ Branch 29 taken 282 times.
✓ Branch 30 taken 279 times.
✓ Branch 31 taken 284 times.
✓ Branch 32 taken 558 times.
✓ Branch 33 taken 1116 times.
✓ Branch 34 taken 780 times.
✓ Branch 35 taken 279 times.
✓ Branch 36 taken 545 times.
✓ Branch 37 taken 1116 times.
✓ Branch 38 taken 279 times.
✓ Branch 39 taken 279 times.
✓ Branch 40 taken 279 times.
✓ Branch 41 taken 279 times.
✓ Branch 42 taken 279 times.
✓ Branch 43 taken 561 times.
✓ Branch 44 taken 558 times.
✓ Branch 45 taken 279 times.
✓ Branch 46 taken 840 times.
✓ Branch 47 taken 843 times.
✓ Branch 48 taken 1128 times.
✓ Branch 49 taken 279 times.
✓ Branch 50 taken 279 times.
✓ Branch 51 taken 279 times.
✓ Branch 52 taken 279 times.
✓ Branch 53 taken 279 times.
✓ Branch 54 taken 306 times.
✓ Branch 55 taken 10652 times.
✓ Branch 56 taken 2872 times.
✓ Branch 57 taken 842 times.
✓ Branch 58 taken 3261 times.
✓ Branch 59 taken 11005 times.
72192 switch(tempitem.type)
7997 {
7998 case itype_sword:
7999 {
8000 17547 tempitem.flags &= ~(item_flag5);
8001 17547 tempitem.misc3 = 0;
8002 17547 tempitem.misc4 = 0;
8003 17547 tempitem.misc5 = 0;
8004 17547 tempitem.misc6 = 0;
8005 17547 tempitem.misc7 = 0;
8006 17547 tempitem.misc8 = 0;
8007 17547 tempitem.misc9 = 0;
8008 17547 tempitem.misc10 = 0;
8009 17547 tempitem.wpn4 = 0;
8010 17547 tempitem.wpn5 = 0;
8011 17547 tempitem.wpn6 = 0;
8012 17547 tempitem.wpn7 = 0;
8013 17547 tempitem.wpn8 = 0;
8014 17547 tempitem.wpn9 = 0;
8015 17547 tempitem.wpn10 = 0;
8016 17547 break;
8017 }
8018 case itype_brang:
8019 {
8020 844 tempitem.flags &= ~(item_flag4 | item_flag5);
8021 844 tempitem.misc2 = 0;
8022 844 tempitem.misc5 = 0;
8023 844 tempitem.misc6 = 0;
8024 844 tempitem.misc7 = 0;
8025 844 tempitem.misc8 = 0;
8026 844 tempitem.misc9 = 0;
8027 844 tempitem.misc10 = 0;
8028 844 tempitem.wpn4 = 0;
8029 844 tempitem.wpn5 = 0;
8030 844 tempitem.wpn6 = 0;
8031 844 tempitem.wpn7 = 0;
8032 844 tempitem.wpn8 = 0;
8033 844 tempitem.wpn9 = 0;
8034 844 tempitem.wpn10 = 0;
8035 844 break;
8036 }
8037 case itype_arrow:
8038 {
8039 831 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8040 831 tempitem.misc2 = 0;
8041 831 tempitem.misc3 = 0;
8042 831 tempitem.misc4 = 0;
8043 831 tempitem.misc5 = 0;
8044 831 tempitem.misc6 = 0;
8045 831 tempitem.misc7 = 0;
8046 831 tempitem.misc8 = 0;
8047 831 tempitem.misc9 = 0;
8048 831 tempitem.misc10 = 0;
8049 831 tempitem.wpn4 = 0;
8050 831 tempitem.wpn5 = 0;
8051 831 tempitem.wpn6 = 0;
8052 831 tempitem.wpn7 = 0;
8053 831 tempitem.wpn8 = 0;
8054 831 tempitem.wpn9 = 0;
8055 831 tempitem.wpn10 = 0;
8056 831 break;
8057 }
8058 case itype_candle:
8059 {
8060 600 tempitem.flags &= ~ (item_flag3 | item_flag5);
8061 600 tempitem.misc1 = 0;
8062 600 tempitem.misc2 = 0;
8063 600 tempitem.misc3 = 0;
8064 600 tempitem.misc4 = 0;
8065 600 tempitem.misc5 = 0;
8066 600 tempitem.misc6 = 0;
8067 600 tempitem.misc7 = 0;
8068 600 tempitem.misc8 = 0;
8069 600 tempitem.misc9 = 0;
8070 600 tempitem.misc10 = 0;
8071 600 tempitem.wpn4 = 0;
8072 600 tempitem.wpn5 = 0;
8073 600 tempitem.wpn6 = 0;
8074 600 tempitem.wpn7 = 0;
8075 600 tempitem.wpn8 = 0;
8076 600 tempitem.wpn9 = 0;
8077 600 tempitem.wpn10 = 0;
8078 600 break;
8079 }
8080 case itype_whistle:
8081 {
8082 327 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8083 327 tempitem.misc3 = 0;
8084 327 tempitem.misc4 = 0;
8085 327 tempitem.misc5 = 0;
8086 327 tempitem.misc6 = 0;
8087 327 tempitem.misc7 = 0;
8088 327 tempitem.misc8 = 0;
8089 327 tempitem.misc9 = 0;
8090 327 tempitem.misc10 = 0;
8091 327 tempitem.wpn2 = 0;
8092 327 tempitem.wpn3 = 0;
8093 327 tempitem.wpn4 = 0;
8094 327 tempitem.wpn5 = 0;
8095 327 tempitem.wpn6 = 0;
8096 327 tempitem.wpn7 = 0;
8097 327 tempitem.wpn8 = 0;
8098 327 tempitem.wpn9 = 0;
8099 327 tempitem.wpn10 = 0;
8100 327 break;
8101 }
8102 case itype_bait:
8103 {
8104 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8105 282 tempitem.misc2 = 0;
8106 282 tempitem.misc3 = 0;
8107 282 tempitem.misc4 = 0;
8108 282 tempitem.misc5 = 0;
8109 282 tempitem.misc6 = 0;
8110 282 tempitem.misc7 = 0;
8111 282 tempitem.misc8 = 0;
8112 282 tempitem.misc9 = 0;
8113 282 tempitem.misc10 = 0;
8114 282 tempitem.wpn2 = 0;
8115 282 tempitem.wpn3 = 0;
8116 282 tempitem.wpn4 = 0;
8117 282 tempitem.wpn5 = 0;
8118 282 tempitem.wpn6 = 0;
8119 282 tempitem.wpn7 = 0;
8120 282 tempitem.wpn8 = 0;
8121 282 tempitem.wpn9 = 0;
8122 282 tempitem.wpn10 = 0;
8123 282 break;
8124 }
8125 case itype_letter:
8126 {
8127 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8128 558 tempitem.misc1 = 0;
8129 558 tempitem.misc2 = 0;
8130 558 tempitem.misc3 = 0;
8131 558 tempitem.misc4 = 0;
8132 558 tempitem.misc5 = 0;
8133 558 tempitem.misc6 = 0;
8134 558 tempitem.misc7 = 0;
8135 558 tempitem.misc8 = 0;
8136 558 tempitem.misc9 = 0;
8137 558 tempitem.misc10 = 0;
8138 558 tempitem.wpn = 0;
8139 558 tempitem.wpn2 = 0;
8140 558 tempitem.wpn3 = 0;
8141 558 tempitem.wpn4 = 0;
8142 558 tempitem.wpn5 = 0;
8143 558 tempitem.wpn6 = 0;
8144 558 tempitem.wpn7 = 0;
8145 558 tempitem.wpn8 = 0;
8146 558 tempitem.wpn9 = 0;
8147 558 tempitem.wpn10 = 0;
8148 558 break;
8149 }
8150 case itype_potion:
8151 {
8152 614 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8153 614 tempitem.misc3 = 0;
8154 614 tempitem.misc4 = 0;
8155 614 tempitem.misc5 = 0;
8156 614 tempitem.misc6 = 0;
8157 614 tempitem.misc7 = 0;
8158 614 tempitem.misc8 = 0;
8159 614 tempitem.misc9 = 0;
8160 614 tempitem.misc10 = 0;
8161 614 tempitem.wpn = 0;
8162 614 tempitem.wpn2 = 0;
8163 614 tempitem.wpn3 = 0;
8164 614 tempitem.wpn4 = 0;
8165 614 tempitem.wpn5 = 0;
8166 614 tempitem.wpn6 = 0;
8167 614 tempitem.wpn7 = 0;
8168 614 tempitem.wpn8 = 0;
8169 614 tempitem.wpn9 = 0;
8170 614 tempitem.wpn10 = 0;
8171 614 break;
8172 }
8173 case itype_wand:
8174 {
8175 297 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8176 297 tempitem.misc1 = 0;
8177 297 tempitem.misc2 = 0;
8178 297 tempitem.misc3 = 0;
8179 297 tempitem.misc4 = 0;
8180 297 tempitem.misc5 = 0;
8181 297 tempitem.misc6 = 0;
8182 297 tempitem.misc7 = 0;
8183 297 tempitem.misc8 = 0;
8184 297 tempitem.misc9 = 0;
8185 297 tempitem.misc10 = 0;
8186 297 tempitem.wpn4 = 0;
8187 297 tempitem.wpn5 = 0;
8188 297 tempitem.wpn6 = 0;
8189 297 tempitem.wpn7 = 0;
8190 297 tempitem.wpn8 = 0;
8191 297 tempitem.wpn9 = 0;
8192 297 tempitem.wpn10 = 0;
8193 297 break;
8194 }
8195 case itype_ring:
8196 {
8197 917 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8198 917 tempitem.misc2 = 0;
8199 917 tempitem.misc3 = 0;
8200 917 tempitem.misc4 = 0;
8201 917 tempitem.misc5 = 0;
8202 917 tempitem.misc6 = 0;
8203 917 tempitem.misc7 = 0;
8204 917 tempitem.misc8 = 0;
8205 917 tempitem.misc9 = 0;
8206 917 tempitem.misc10 = 0;
8207 917 tempitem.wpn = 0;
8208 917 tempitem.wpn2 = 0;
8209 917 tempitem.wpn3 = 0;
8210 917 tempitem.wpn4 = 0;
8211 917 tempitem.wpn5 = 0;
8212 917 tempitem.wpn6 = 0;
8213 917 tempitem.wpn7 = 0;
8214 917 tempitem.wpn8 = 0;
8215 917 tempitem.wpn9 = 0;
8216 917 tempitem.wpn10 = 0;
8217 917 break;
8218 }
8219 case itype_wallet:
8220 {
8221 892 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8222 892 tempitem.misc3 = 0;
8223 892 tempitem.misc4 = 0;
8224 892 tempitem.misc5 = 0;
8225 892 tempitem.misc6 = 0;
8226 892 tempitem.misc7 = 0;
8227 892 tempitem.misc8 = 0;
8228 892 tempitem.misc9 = 0;
8229 892 tempitem.misc10 = 0;
8230 892 tempitem.wpn = 0;
8231 892 tempitem.wpn2 = 0;
8232 892 tempitem.wpn3 = 0;
8233 892 tempitem.wpn4 = 0;
8234 892 tempitem.wpn5 = 0;
8235 892 tempitem.wpn6 = 0;
8236 892 tempitem.wpn7 = 0;
8237 892 tempitem.wpn8 = 0;
8238 892 tempitem.wpn9 = 0;
8239 892 tempitem.wpn10 = 0;
8240 892 break;
8241 }
8242 case itype_amulet:
8243 {
8244 557 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8245 557 tempitem.misc1 = 0;
8246 557 tempitem.misc2 = 0;
8247 557 tempitem.misc3 = 0;
8248 557 tempitem.misc4 = 0;
8249 557 tempitem.misc5 = 0;
8250 557 tempitem.misc6 = 0;
8251 557 tempitem.misc7 = 0;
8252 557 tempitem.misc8 = 0;
8253 557 tempitem.misc9 = 0;
8254 557 tempitem.misc10 = 0;
8255 557 tempitem.wpn = 0;
8256 557 tempitem.wpn2 = 0;
8257 557 tempitem.wpn3 = 0;
8258 557 tempitem.wpn4 = 0;
8259 557 tempitem.wpn5 = 0;
8260 557 tempitem.wpn6 = 0;
8261 557 tempitem.wpn7 = 0;
8262 557 tempitem.wpn8 = 0;
8263 557 tempitem.wpn9 = 0;
8264 557 tempitem.wpn10 = 0;
8265 557 break;
8266 }
8267 case itype_shield:
8268 {
8269 858 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8270 858 tempitem.misc3 = 0;
8271 858 tempitem.misc4 = 0;
8272 858 tempitem.misc5 = 0;
8273 858 tempitem.misc6 = 0;
8274 858 tempitem.misc7 = 0;
8275 858 tempitem.misc8 = 0;
8276 858 tempitem.misc9 = 0;
8277 858 tempitem.misc10 = 0;
8278 858 tempitem.wpn = 0;
8279 858 tempitem.wpn2 = 0;
8280 858 tempitem.wpn3 = 0;
8281 858 tempitem.wpn4 = 0;
8282 858 tempitem.wpn5 = 0;
8283 858 tempitem.wpn6 = 0;
8284 858 tempitem.wpn7 = 0;
8285 858 tempitem.wpn8 = 0;
8286 858 tempitem.wpn9 = 0;
8287 858 tempitem.wpn10 = 0;
8288 858 break;
8289 }
8290 case itype_bow:
8291 {
8292 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8293 558 tempitem.misc1 = 0;
8294 558 tempitem.misc2 = 0;
8295 558 tempitem.misc3 = 0;
8296 558 tempitem.misc4 = 0;
8297 558 tempitem.misc5 = 0;
8298 558 tempitem.misc6 = 0;
8299 558 tempitem.misc7 = 0;
8300 558 tempitem.misc8 = 0;
8301 558 tempitem.misc9 = 0;
8302 558 tempitem.misc10 = 0;
8303 558 tempitem.wpn = 0;
8304 558 tempitem.wpn2 = 0;
8305 558 tempitem.wpn3 = 0;
8306 558 tempitem.wpn4 = 0;
8307 558 tempitem.wpn5 = 0;
8308 558 tempitem.wpn6 = 0;
8309 558 tempitem.wpn7 = 0;
8310 558 tempitem.wpn8 = 0;
8311 558 tempitem.wpn9 = 0;
8312 558 tempitem.wpn10 = 0;
8313 558 break;
8314 }
8315 case itype_raft:
8316 {
8317 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8318 279 tempitem.misc1 = 0;
8319 279 tempitem.misc2 = 0;
8320 279 tempitem.misc3 = 0;
8321 279 tempitem.misc4 = 0;
8322 279 tempitem.misc5 = 0;
8323 279 tempitem.misc6 = 0;
8324 279 tempitem.misc7 = 0;
8325 279 tempitem.misc8 = 0;
8326 279 tempitem.misc9 = 0;
8327 279 tempitem.misc10 = 0;
8328 279 tempitem.wpn = 0;
8329 279 tempitem.wpn2 = 0;
8330 279 tempitem.wpn3 = 0;
8331 279 tempitem.wpn4 = 0;
8332 279 tempitem.wpn5 = 0;
8333 279 tempitem.wpn6 = 0;
8334 279 tempitem.wpn7 = 0;
8335 279 tempitem.wpn8 = 0;
8336 279 tempitem.wpn9 = 0;
8337 279 tempitem.wpn10 = 0;
8338 279 break;
8339 }
8340 case itype_ladder:
8341 {
8342 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8343 558 tempitem.misc1 = 0;
8344 558 tempitem.misc2 = 0;
8345 558 tempitem.misc3 = 0;
8346 558 tempitem.misc4 = 0;
8347 558 tempitem.misc5 = 0;
8348 558 tempitem.misc6 = 0;
8349 558 tempitem.misc7 = 0;
8350 558 tempitem.misc8 = 0;
8351 558 tempitem.misc9 = 0;
8352 558 tempitem.misc10 = 0;
8353 558 tempitem.wpn = 0;
8354 558 tempitem.wpn2 = 0;
8355 558 tempitem.wpn3 = 0;
8356 558 tempitem.wpn4 = 0;
8357 558 tempitem.wpn5 = 0;
8358 558 tempitem.wpn6 = 0;
8359 558 tempitem.wpn7 = 0;
8360 558 tempitem.wpn8 = 0;
8361 558 tempitem.wpn9 = 0;
8362 558 tempitem.wpn10 = 0;
8363 558 break;
8364 }
8365 case itype_book:
8366 {
8367 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8368 295 tempitem.misc1 = 0;
8369 295 tempitem.misc2 = 0;
8370 295 tempitem.misc3 = 0;
8371 295 tempitem.misc4 = 0;
8372 295 tempitem.misc5 = 0;
8373 295 tempitem.misc6 = 0;
8374 295 tempitem.misc7 = 0;
8375 295 tempitem.misc8 = 0;
8376 295 tempitem.misc9 = 0;
8377 295 tempitem.misc10 = 0;
8378 295 tempitem.wpn3 = 0;
8379 295 tempitem.wpn4 = 0;
8380 295 tempitem.wpn5 = 0;
8381 295 tempitem.wpn6 = 0;
8382 295 tempitem.wpn7 = 0;
8383 295 tempitem.wpn8 = 0;
8384 295 tempitem.wpn9 = 0;
8385 295 tempitem.wpn10 = 0;
8386 295 break;
8387 }
8388 case itype_magickey:
8389 {
8390 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8391 279 tempitem.misc1 = 0;
8392 279 tempitem.misc2 = 0;
8393 279 tempitem.misc3 = 0;
8394 279 tempitem.misc4 = 0;
8395 279 tempitem.misc5 = 0;
8396 279 tempitem.misc6 = 0;
8397 279 tempitem.misc7 = 0;
8398 279 tempitem.misc8 = 0;
8399 279 tempitem.misc9 = 0;
8400 279 tempitem.misc10 = 0;
8401 279 tempitem.wpn = 0;
8402 279 tempitem.wpn2 = 0;
8403 279 tempitem.wpn3 = 0;
8404 279 tempitem.wpn4 = 0;
8405 279 tempitem.wpn5 = 0;
8406 279 tempitem.wpn6 = 0;
8407 279 tempitem.wpn7 = 0;
8408 279 tempitem.wpn8 = 0;
8409 279 tempitem.wpn9 = 0;
8410 279 tempitem.wpn10 = 0;
8411 279 break;
8412 }
8413 case itype_bracelet:
8414 {
8415 846 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8416 846 tempitem.misc1 = 0;
8417 846 tempitem.misc2 = 0;
8418 846 tempitem.misc3 = 0;
8419 846 tempitem.misc4 = 0;
8420 846 tempitem.misc5 = 0;
8421 846 tempitem.misc6 = 0;
8422 846 tempitem.misc7 = 0;
8423 846 tempitem.misc8 = 0;
8424 846 tempitem.misc9 = 0;
8425 846 tempitem.misc10 = 0;
8426 846 tempitem.wpn = 0;
8427 846 tempitem.wpn2 = 0;
8428 846 tempitem.wpn3 = 0;
8429 846 tempitem.wpn4 = 0;
8430 846 tempitem.wpn5 = 0;
8431 846 tempitem.wpn6 = 0;
8432 846 tempitem.wpn7 = 0;
8433 846 tempitem.wpn8 = 0;
8434 846 tempitem.wpn9 = 0;
8435 846 tempitem.wpn10 = 0;
8436 846 break;
8437 }
8438 case itype_flippers:
8439 {
8440 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8441 282 tempitem.misc1 = 0;
8442 282 tempitem.misc2 = 0;
8443 282 tempitem.misc3 = 0;
8444 282 tempitem.misc4 = 0;
8445 282 tempitem.misc5 = 0;
8446 282 tempitem.misc6 = 0;
8447 282 tempitem.misc7 = 0;
8448 282 tempitem.misc8 = 0;
8449 282 tempitem.misc9 = 0;
8450 282 tempitem.misc10 = 0;
8451 282 tempitem.wpn = 0;
8452 282 tempitem.wpn2 = 0;
8453 282 tempitem.wpn3 = 0;
8454 282 tempitem.wpn4 = 0;
8455 282 tempitem.wpn5 = 0;
8456 282 tempitem.wpn6 = 0;
8457 282 tempitem.wpn7 = 0;
8458 282 tempitem.wpn8 = 0;
8459 282 tempitem.wpn9 = 0;
8460 282 tempitem.wpn10 = 0;
8461 282 break;
8462 }
8463 case itype_boots:
8464 {
8465 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8466 285 tempitem.misc1 = 0;
8467 285 tempitem.misc2 = 0;
8468 285 tempitem.misc3 = 0;
8469 285 tempitem.misc4 = 0;
8470 285 tempitem.misc5 = 0;
8471 285 tempitem.misc6 = 0;
8472 285 tempitem.misc7 = 0;
8473 285 tempitem.misc8 = 0;
8474 285 tempitem.misc9 = 0;
8475 285 tempitem.misc10 = 0;
8476 285 tempitem.wpn = 0;
8477 285 tempitem.wpn2 = 0;
8478 285 tempitem.wpn3 = 0;
8479 285 tempitem.wpn4 = 0;
8480 285 tempitem.wpn5 = 0;
8481 285 tempitem.wpn6 = 0;
8482 285 tempitem.wpn7 = 0;
8483 285 tempitem.wpn8 = 0;
8484 285 tempitem.wpn9 = 0;
8485 285 tempitem.wpn10 = 0;
8486 285 break;
8487 }
8488 case itype_hookshot:
8489 {
8490 560 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8491 560 tempitem.misc5 = 0;
8492 560 tempitem.misc6 = 0;
8493 560 tempitem.misc7 = 0;
8494 560 tempitem.misc8 = 0;
8495 560 tempitem.misc9 = 0;
8496 560 tempitem.misc10 = 0;
8497 560 tempitem.wpn5 = 0;
8498 560 tempitem.wpn6 = 0;
8499 560 tempitem.wpn7 = 0;
8500 560 tempitem.wpn8 = 0;
8501 560 tempitem.wpn9 = 0;
8502 560 tempitem.wpn10 = 0;
8503 560 break;
8504 }
8505 case itype_lens:
8506 {
8507 255 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8508 255 tempitem.misc2 = 0;
8509 255 tempitem.misc3 = 0;
8510 255 tempitem.misc4 = 0;
8511 255 tempitem.misc5 = 0;
8512 255 tempitem.misc6 = 0;
8513 255 tempitem.misc7 = 0;
8514 255 tempitem.misc8 = 0;
8515 255 tempitem.misc9 = 0;
8516 255 tempitem.misc10 = 0;
8517 255 tempitem.wpn = 0;
8518 255 tempitem.wpn2 = 0;
8519 255 tempitem.wpn3 = 0;
8520 255 tempitem.wpn4 = 0;
8521 255 tempitem.wpn5 = 0;
8522 255 tempitem.wpn6 = 0;
8523 255 tempitem.wpn7 = 0;
8524 255 tempitem.wpn8 = 0;
8525 255 tempitem.wpn9 = 0;
8526 255 tempitem.wpn10 = 0;
8527 255 break;
8528 }
8529 case itype_hammer:
8530 {
8531 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8532 282 tempitem.misc1 = 0;
8533 282 tempitem.misc2 = 0;
8534 282 tempitem.misc3 = 0;
8535 282 tempitem.misc4 = 0;
8536 282 tempitem.misc5 = 0;
8537 282 tempitem.misc6 = 0;
8538 282 tempitem.misc7 = 0;
8539 282 tempitem.misc8 = 0;
8540 282 tempitem.misc9 = 0;
8541 282 tempitem.misc10 = 0;
8542 282 tempitem.wpn3 = 0;
8543 282 tempitem.wpn4 = 0;
8544 282 tempitem.wpn5 = 0;
8545 282 tempitem.wpn6 = 0;
8546 282 tempitem.wpn7 = 0;
8547 282 tempitem.wpn8 = 0;
8548 282 tempitem.wpn9 = 0;
8549 282 tempitem.wpn10 = 0;
8550 282 break;
8551 }
8552 case itype_divinefire:
8553 {
8554 279 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8555 279 tempitem.misc3 = 0;
8556 279 tempitem.misc4 = 0;
8557 279 tempitem.misc5 = 0;
8558 279 tempitem.misc6 = 0;
8559 279 tempitem.misc7 = 0;
8560 279 tempitem.misc8 = 0;
8561 279 tempitem.misc9 = 0;
8562 279 tempitem.misc10 = 0;
8563 279 tempitem.wpn6 = 0;
8564 279 tempitem.wpn7 = 0;
8565 279 tempitem.wpn8 = 0;
8566 279 tempitem.wpn9 = 0;
8567 279 tempitem.wpn10 = 0;
8568 279 break;
8569 }
8570 case itype_divineescape:
8571 {
8572 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8573 279 tempitem.misc2 = 0;
8574 279 tempitem.misc3 = 0;
8575 279 tempitem.misc4 = 0;
8576 279 tempitem.misc5 = 0;
8577 279 tempitem.misc6 = 0;
8578 279 tempitem.misc7 = 0;
8579 279 tempitem.misc8 = 0;
8580 279 tempitem.misc9 = 0;
8581 279 tempitem.misc10 = 0;
8582 279 tempitem.wpn = 0;
8583 279 tempitem.wpn2 = 0;
8584 279 tempitem.wpn3 = 0;
8585 279 tempitem.wpn4 = 0;
8586 279 tempitem.wpn5 = 0;
8587 279 tempitem.wpn6 = 0;
8588 279 tempitem.wpn7 = 0;
8589 279 tempitem.wpn8 = 0;
8590 279 tempitem.wpn9 = 0;
8591 279 tempitem.wpn10 = 0;
8592 279 break;
8593 }
8594 case itype_divineprotection:
8595 {
8596 279 tempitem.flags &= ~ (item_flag5);
8597 279 tempitem.misc2 = 0;
8598 279 tempitem.misc3 = 0;
8599 279 tempitem.misc4 = 0;
8600 279 tempitem.misc5 = 0;
8601 279 tempitem.misc6 = 0;
8602 279 tempitem.misc7 = 0;
8603 279 tempitem.misc8 = 0;
8604 279 tempitem.misc9 = 0;
8605 279 tempitem.misc10 = 0;
8606 279 break;
8607 }
8608 case itype_bomb:
8609 {
8610 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8611 295 tempitem.misc4 = 0;
8612 295 tempitem.misc5 = 0;
8613 295 tempitem.misc6 = 0;
8614 295 tempitem.misc7 = 0;
8615 295 tempitem.misc8 = 0;
8616 295 tempitem.misc9 = 0;
8617 295 tempitem.misc10 = 0;
8618 295 tempitem.wpn3 = 0;
8619 295 tempitem.wpn4 = 0;
8620 295 tempitem.wpn5 = 0;
8621 295 tempitem.wpn6 = 0;
8622 295 tempitem.wpn7 = 0;
8623 295 tempitem.wpn8 = 0;
8624 295 tempitem.wpn9 = 0;
8625 295 tempitem.wpn10 = 0;
8626 295 break;
8627 }
8628 case itype_sbomb:
8629 {
8630 281 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8631 281 tempitem.misc4 = 0;
8632 281 tempitem.misc5 = 0;
8633 281 tempitem.misc6 = 0;
8634 281 tempitem.misc7 = 0;
8635 281 tempitem.misc8 = 0;
8636 281 tempitem.misc9 = 0;
8637 281 tempitem.misc10 = 0;
8638 281 tempitem.wpn3 = 0;
8639 281 tempitem.wpn4 = 0;
8640 281 tempitem.wpn5 = 0;
8641 281 tempitem.wpn6 = 0;
8642 281 tempitem.wpn7 = 0;
8643 281 tempitem.wpn8 = 0;
8644 281 tempitem.wpn9 = 0;
8645 281 tempitem.wpn10 = 0;
8646 281 break;
8647 }
8648 case itype_clock:
8649 {
8650 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8651 282 tempitem.misc2 = 0;
8652 282 tempitem.misc3 = 0;
8653 282 tempitem.misc4 = 0;
8654 282 tempitem.misc5 = 0;
8655 282 tempitem.misc6 = 0;
8656 282 tempitem.misc7 = 0;
8657 282 tempitem.misc8 = 0;
8658 282 tempitem.misc9 = 0;
8659 282 tempitem.misc10 = 0;
8660 282 tempitem.wpn = 0;
8661 282 tempitem.wpn2 = 0;
8662 282 tempitem.wpn3 = 0;
8663 282 tempitem.wpn4 = 0;
8664 282 tempitem.wpn5 = 0;
8665 282 tempitem.wpn6 = 0;
8666 282 tempitem.wpn7 = 0;
8667 282 tempitem.wpn8 = 0;
8668 282 tempitem.wpn9 = 0;
8669 282 tempitem.wpn10 = 0;
8670 282 break;
8671 }
8672 case itype_key:
8673 {
8674 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8675 279 tempitem.misc1 = 0;
8676 279 tempitem.misc2 = 0;
8677 279 tempitem.misc3 = 0;
8678 279 tempitem.misc4 = 0;
8679 279 tempitem.misc5 = 0;
8680 279 tempitem.misc6 = 0;
8681 279 tempitem.misc7 = 0;
8682 279 tempitem.misc8 = 0;
8683 279 tempitem.misc9 = 0;
8684 279 tempitem.misc10 = 0;
8685 279 tempitem.wpn = 0;
8686 279 tempitem.wpn2 = 0;
8687 279 tempitem.wpn3 = 0;
8688 279 tempitem.wpn4 = 0;
8689 279 tempitem.wpn5 = 0;
8690 279 tempitem.wpn6 = 0;
8691 279 tempitem.wpn7 = 0;
8692 279 tempitem.wpn8 = 0;
8693 279 tempitem.wpn9 = 0;
8694 279 tempitem.wpn10 = 0;
8695 279 break;
8696 }
8697 case itype_magiccontainer:
8698 {
8699 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8700 284 tempitem.misc1 = 0;
8701 284 tempitem.misc2 = 0;
8702 284 tempitem.misc3 = 0;
8703 284 tempitem.misc4 = 0;
8704 284 tempitem.misc5 = 0;
8705 284 tempitem.misc6 = 0;
8706 284 tempitem.misc7 = 0;
8707 284 tempitem.misc8 = 0;
8708 284 tempitem.misc9 = 0;
8709 284 tempitem.misc10 = 0;
8710 284 tempitem.wpn = 0;
8711 284 tempitem.wpn2 = 0;
8712 284 tempitem.wpn3 = 0;
8713 284 tempitem.wpn4 = 0;
8714 284 tempitem.wpn5 = 0;
8715 284 tempitem.wpn6 = 0;
8716 284 tempitem.wpn7 = 0;
8717 284 tempitem.wpn8 = 0;
8718 284 tempitem.wpn9 = 0;
8719 284 tempitem.wpn10 = 0;
8720 284 break;
8721 }
8722 case itype_triforcepiece:
8723 {
8724 558 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8725 558 tempitem.misc3 = 0;
8726 558 tempitem.misc4 = 0;
8727 558 tempitem.misc5 = 0;
8728 558 tempitem.misc6 = 0;
8729 558 tempitem.misc7 = 0;
8730 558 tempitem.misc8 = 0;
8731 558 tempitem.misc9 = 0;
8732 558 tempitem.misc10 = 0;
8733 558 tempitem.wpn = 0;
8734 558 tempitem.wpn2 = 0;
8735 558 tempitem.wpn3 = 0;
8736 558 tempitem.wpn4 = 0;
8737 558 tempitem.wpn5 = 0;
8738 558 tempitem.wpn6 = 0;
8739 558 tempitem.wpn7 = 0;
8740 558 tempitem.wpn8 = 0;
8741 558 tempitem.wpn9 = 0;
8742 558 tempitem.wpn10 = 0;
8743 558 break;
8744 }
8745 case itype_map: case itype_compass: case itype_bosskey:
8746 {
8747 842 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8748 842 tempitem.misc1 = 0;
8749 842 tempitem.misc2 = 0;
8750 842 tempitem.misc3 = 0;
8751 842 tempitem.misc4 = 0;
8752 842 tempitem.misc5 = 0;
8753 842 tempitem.misc6 = 0;
8754 842 tempitem.misc7 = 0;
8755 842 tempitem.misc8 = 0;
8756 842 tempitem.misc9 = 0;
8757 842 tempitem.misc10 = 0;
8758 842 tempitem.wpn = 0;
8759 842 tempitem.wpn2 = 0;
8760 842 tempitem.wpn3 = 0;
8761 842 tempitem.wpn4 = 0;
8762 842 tempitem.wpn5 = 0;
8763 842 tempitem.wpn6 = 0;
8764 842 tempitem.wpn7 = 0;
8765 842 tempitem.wpn8 = 0;
8766 842 tempitem.wpn9 = 0;
8767 842 tempitem.wpn10 = 0;
8768 842 break;
8769 }
8770 case itype_quiver:
8771 {
8772 1116 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8773 1116 tempitem.misc3 = 0;
8774 1116 tempitem.misc4 = 0;
8775 1116 tempitem.misc5 = 0;
8776 1116 tempitem.misc6 = 0;
8777 1116 tempitem.misc7 = 0;
8778 1116 tempitem.misc8 = 0;
8779 1116 tempitem.misc9 = 0;
8780 1116 tempitem.misc10 = 0;
8781 1116 tempitem.wpn = 0;
8782 1116 tempitem.wpn2 = 0;
8783 1116 tempitem.wpn3 = 0;
8784 1116 tempitem.wpn4 = 0;
8785 1116 tempitem.wpn5 = 0;
8786 1116 tempitem.wpn6 = 0;
8787 1116 tempitem.wpn7 = 0;
8788 1116 tempitem.wpn8 = 0;
8789 1116 tempitem.wpn9 = 0;
8790 1116 tempitem.wpn10 = 0;
8791 1116 break;
8792 }
8793 case itype_lkey:
8794 {
8795 780 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8796 780 tempitem.misc1 = 0;
8797 780 tempitem.misc2 = 0;
8798 780 tempitem.misc3 = 0;
8799 780 tempitem.misc4 = 0;
8800 780 tempitem.misc5 = 0;
8801 780 tempitem.misc6 = 0;
8802 780 tempitem.misc7 = 0;
8803 780 tempitem.misc8 = 0;
8804 780 tempitem.misc9 = 0;
8805 780 tempitem.misc10 = 0;
8806 780 tempitem.wpn = 0;
8807 780 tempitem.wpn2 = 0;
8808 780 tempitem.wpn3 = 0;
8809 780 tempitem.wpn4 = 0;
8810 780 tempitem.wpn5 = 0;
8811 780 tempitem.wpn6 = 0;
8812 780 tempitem.wpn7 = 0;
8813 780 tempitem.wpn8 = 0;
8814 780 tempitem.wpn9 = 0;
8815 780 tempitem.wpn10 = 0;
8816 780 break;
8817 }
8818 case itype_cbyrna:
8819 {
8820 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8821 279 tempitem.misc4 = 0;
8822 279 tempitem.misc5 = 0;
8823 279 tempitem.misc6 = 0;
8824 279 tempitem.misc7 = 0;
8825 279 tempitem.misc8 = 0;
8826 279 tempitem.misc9 = 0;
8827 279 tempitem.misc10 = 0;
8828 279 tempitem.wpn6 = 0;
8829 279 tempitem.wpn7 = 0;
8830 279 tempitem.wpn8 = 0;
8831 279 tempitem.wpn9 = 0;
8832 279 tempitem.wpn10 = 0;
8833 279 break;
8834 }
8835 case itype_rupee: case itype_arrowammo:
8836 {
8837 3261 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8838 3261 tempitem.misc1 = 0;
8839 3261 tempitem.misc2 = 0;
8840 3261 tempitem.misc3 = 0;
8841 3261 tempitem.misc4 = 0;
8842 3261 tempitem.misc5 = 0;
8843 3261 tempitem.misc6 = 0;
8844 3261 tempitem.misc7 = 0;
8845 3261 tempitem.misc8 = 0;
8846 3261 tempitem.misc9 = 0;
8847 3261 tempitem.misc10 = 0;
8848 3261 tempitem.wpn = 0;
8849 3261 tempitem.wpn2 = 0;
8850 3261 tempitem.wpn3 = 0;
8851 3261 tempitem.wpn4 = 0;
8852 3261 tempitem.wpn5 = 0;
8853 3261 tempitem.wpn6 = 0;
8854 3261 tempitem.wpn7 = 0;
8855 3261 tempitem.wpn8 = 0;
8856 3261 tempitem.wpn9 = 0;
8857 3261 tempitem.wpn10 = 0;
8858 3261 break;
8859 }
8860 case itype_fairy:
8861 {
8862 545 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8863 545 tempitem.misc4 = 0;
8864 545 tempitem.misc5 = 0;
8865 545 tempitem.misc6 = 0;
8866 545 tempitem.misc7 = 0;
8867 545 tempitem.misc8 = 0;
8868 545 tempitem.misc9 = 0;
8869 545 tempitem.misc10 = 0;
8870 545 tempitem.wpn = 0;
8871 545 tempitem.wpn2 = 0;
8872 545 tempitem.wpn3 = 0;
8873 545 tempitem.wpn4 = 0;
8874 545 tempitem.wpn5 = 0;
8875 545 tempitem.wpn6 = 0;
8876 545 tempitem.wpn7 = 0;
8877 545 tempitem.wpn8 = 0;
8878 545 tempitem.wpn9 = 0;
8879 545 tempitem.wpn10 = 0;
8880 545 break;
8881 }
8882 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8883 {
8884 2872 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8885 2872 tempitem.misc1 = 0;
8886 2872 tempitem.misc2 = 0;
8887 2872 tempitem.misc3 = 0;
8888 2872 tempitem.misc4 = 0;
8889 2872 tempitem.misc5 = 0;
8890 2872 tempitem.misc6 = 0;
8891 2872 tempitem.misc7 = 0;
8892 2872 tempitem.misc8 = 0;
8893 2872 tempitem.misc9 = 0;
8894 2872 tempitem.misc10 = 0;
8895 2872 tempitem.wpn = 0;
8896 2872 tempitem.wpn2 = 0;
8897 2872 tempitem.wpn3 = 0;
8898 2872 tempitem.wpn4 = 0;
8899 2872 tempitem.wpn5 = 0;
8900 2872 tempitem.wpn6 = 0;
8901 2872 tempitem.wpn7 = 0;
8902 2872 tempitem.wpn8 = 0;
8903 2872 tempitem.wpn9 = 0;
8904 2872 tempitem.wpn10 = 0;
8905 2872 break;
8906 }
8907 case itype_bombbag:
8908 {
8909 1116 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8910 1116 tempitem.misc3 = 0;
8911 1116 tempitem.misc4 = 0;
8912 1116 tempitem.misc5 = 0;
8913 1116 tempitem.misc6 = 0;
8914 1116 tempitem.misc7 = 0;
8915 1116 tempitem.misc8 = 0;
8916 1116 tempitem.misc9 = 0;
8917 1116 tempitem.misc10 = 0;
8918 1116 tempitem.wpn = 0;
8919 1116 tempitem.wpn2 = 0;
8920 1116 tempitem.wpn3 = 0;
8921 1116 tempitem.wpn4 = 0;
8922 1116 tempitem.wpn5 = 0;
8923 1116 tempitem.wpn6 = 0;
8924 1116 tempitem.wpn7 = 0;
8925 1116 tempitem.wpn8 = 0;
8926 1116 tempitem.wpn9 = 0;
8927 1116 tempitem.wpn10 = 0;
8928 1116 break;
8929 }
8930 case itype_rocs:
8931 {
8932 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8933 279 tempitem.misc1 = 0;
8934 279 tempitem.misc2 = 0;
8935 279 tempitem.misc3 = 0;
8936 279 tempitem.misc4 = 0;
8937 279 tempitem.misc5 = 0;
8938 279 tempitem.misc6 = 0;
8939 279 tempitem.misc7 = 0;
8940 279 tempitem.misc8 = 0;
8941 279 tempitem.misc9 = 0;
8942 279 tempitem.misc10 = 0;
8943 279 tempitem.wpn = 0;
8944 279 tempitem.wpn2 = 0;
8945 279 tempitem.wpn3 = 0;
8946 279 tempitem.wpn4 = 0;
8947 279 tempitem.wpn5 = 0;
8948 279 tempitem.wpn6 = 0;
8949 279 tempitem.wpn7 = 0;
8950 279 tempitem.wpn8 = 0;
8951 279 tempitem.wpn9 = 0;
8952 279 tempitem.wpn10 = 0;
8953 279 break;
8954 }
8955 case itype_hoverboots:
8956 {
8957 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8958 279 tempitem.misc2 = 0;
8959 279 tempitem.misc3 = 0;
8960 279 tempitem.misc4 = 0;
8961 279 tempitem.misc5 = 0;
8962 279 tempitem.misc6 = 0;
8963 279 tempitem.misc7 = 0;
8964 279 tempitem.misc8 = 0;
8965 279 tempitem.misc9 = 0;
8966 279 tempitem.misc10 = 0;
8967 279 tempitem.wpn2 = 0;
8968 279 tempitem.wpn3 = 0;
8969 279 tempitem.wpn4 = 0;
8970 279 tempitem.wpn5 = 0;
8971 279 tempitem.wpn6 = 0;
8972 279 tempitem.wpn7 = 0;
8973 279 tempitem.wpn8 = 0;
8974 279 tempitem.wpn9 = 0;
8975 279 tempitem.wpn10 = 0;
8976 279 break;
8977 }
8978 case itype_spinscroll:
8979 {
8980 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8981 279 tempitem.misc2 = 0;
8982 279 tempitem.misc3 = 0;
8983 279 tempitem.misc4 = 0;
8984 279 tempitem.misc5 = 0;
8985 279 tempitem.misc6 = 0;
8986 279 tempitem.misc7 = 0;
8987 279 tempitem.misc8 = 0;
8988 279 tempitem.misc9 = 0;
8989 279 tempitem.misc10 = 0;
8990 279 tempitem.wpn = 0;
8991 279 tempitem.wpn2 = 0;
8992 279 tempitem.wpn3 = 0;
8993 279 tempitem.wpn4 = 0;
8994 279 tempitem.wpn5 = 0;
8995 279 tempitem.wpn6 = 0;
8996 279 tempitem.wpn7 = 0;
8997 279 tempitem.wpn8 = 0;
8998 279 tempitem.wpn9 = 0;
8999 279 tempitem.wpn10 = 0;
9000 279 break;
9001 }
9002 case itype_crossscroll:
9003 {
9004 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9005 279 tempitem.misc1 = 0;
9006 279 tempitem.misc2 = 0;
9007 279 tempitem.misc3 = 0;
9008 279 tempitem.misc4 = 0;
9009 279 tempitem.misc5 = 0;
9010 279 tempitem.misc6 = 0;
9011 279 tempitem.misc7 = 0;
9012 279 tempitem.misc8 = 0;
9013 279 tempitem.misc9 = 0;
9014 279 tempitem.misc10 = 0;
9015 279 tempitem.wpn = 0;
9016 279 tempitem.wpn2 = 0;
9017 279 tempitem.wpn3 = 0;
9018 279 tempitem.wpn4 = 0;
9019 279 tempitem.wpn5 = 0;
9020 279 tempitem.wpn6 = 0;
9021 279 tempitem.wpn7 = 0;
9022 279 tempitem.wpn8 = 0;
9023 279 tempitem.wpn9 = 0;
9024 279 tempitem.wpn10 = 0;
9025 279 break;
9026 }
9027 case itype_quakescroll:
9028 {
9029 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9030 279 tempitem.misc3 = 0;
9031 279 tempitem.misc4 = 0;
9032 279 tempitem.misc5 = 0;
9033 279 tempitem.misc6 = 0;
9034 279 tempitem.misc7 = 0;
9035 279 tempitem.misc8 = 0;
9036 279 tempitem.misc9 = 0;
9037 279 tempitem.misc10 = 0;
9038 279 tempitem.wpn = 0;
9039 279 tempitem.wpn2 = 0;
9040 279 tempitem.wpn3 = 0;
9041 279 tempitem.wpn4 = 0;
9042 279 tempitem.wpn5 = 0;
9043 279 tempitem.wpn6 = 0;
9044 279 tempitem.wpn7 = 0;
9045 279 tempitem.wpn8 = 0;
9046 279 tempitem.wpn9 = 0;
9047 279 tempitem.wpn10 = 0;
9048 279 break;
9049 }
9050 case itype_whispring:
9051 {
9052 561 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
9053 561 tempitem.misc2 = 0;
9054 561 tempitem.misc3 = 0;
9055 561 tempitem.misc4 = 0;
9056 561 tempitem.misc5 = 0;
9057 561 tempitem.misc6 = 0;
9058 561 tempitem.misc7 = 0;
9059 561 tempitem.misc8 = 0;
9060 561 tempitem.misc9 = 0;
9061 561 tempitem.misc10 = 0;
9062 561 tempitem.wpn = 0;
9063 561 tempitem.wpn2 = 0;
9064 561 tempitem.wpn3 = 0;
9065 561 tempitem.wpn4 = 0;
9066 561 tempitem.wpn5 = 0;
9067 561 tempitem.wpn6 = 0;
9068 561 tempitem.wpn7 = 0;
9069 561 tempitem.wpn8 = 0;
9070 561 tempitem.wpn9 = 0;
9071 561 tempitem.wpn10 = 0;
9072 561 break;
9073 }
9074 case itype_chargering:
9075 {
9076 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9077 558 tempitem.misc3 = 0;
9078 558 tempitem.misc4 = 0;
9079 558 tempitem.misc5 = 0;
9080 558 tempitem.misc6 = 0;
9081 558 tempitem.misc7 = 0;
9082 558 tempitem.misc8 = 0;
9083 558 tempitem.misc9 = 0;
9084 558 tempitem.misc10 = 0;
9085 558 tempitem.wpn = 0;
9086 558 tempitem.wpn2 = 0;
9087 558 tempitem.wpn3 = 0;
9088 558 tempitem.wpn4 = 0;
9089 558 tempitem.wpn5 = 0;
9090 558 tempitem.wpn6 = 0;
9091 558 tempitem.wpn7 = 0;
9092 558 tempitem.wpn8 = 0;
9093 558 tempitem.wpn9 = 0;
9094 558 tempitem.wpn10 = 0;
9095 558 break;
9096 }
9097 case itype_perilscroll:
9098 {
9099 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9100 279 tempitem.misc2 = 0;
9101 279 tempitem.misc3 = 0;
9102 279 tempitem.misc4 = 0;
9103 279 tempitem.misc5 = 0;
9104 279 tempitem.misc6 = 0;
9105 279 tempitem.misc7 = 0;
9106 279 tempitem.misc8 = 0;
9107 279 tempitem.misc9 = 0;
9108 279 tempitem.misc10 = 0;
9109 279 tempitem.wpn = 0;
9110 279 tempitem.wpn2 = 0;
9111 279 tempitem.wpn3 = 0;
9112 279 tempitem.wpn4 = 0;
9113 279 tempitem.wpn5 = 0;
9114 279 tempitem.wpn6 = 0;
9115 279 tempitem.wpn7 = 0;
9116 279 tempitem.wpn8 = 0;
9117 279 tempitem.wpn9 = 0;
9118 279 tempitem.wpn10 = 0;
9119 279 break;
9120 }
9121 case itype_wealthmedal:
9122 {
9123 840 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
9124 840 tempitem.misc2 = 0;
9125 840 tempitem.misc3 = 0;
9126 840 tempitem.misc4 = 0;
9127 840 tempitem.misc5 = 0;
9128 840 tempitem.misc6 = 0;
9129 840 tempitem.misc7 = 0;
9130 840 tempitem.misc8 = 0;
9131 840 tempitem.misc9 = 0;
9132 840 tempitem.misc10 = 0;
9133 840 tempitem.wpn = 0;
9134 840 tempitem.wpn2 = 0;
9135 840 tempitem.wpn3 = 0;
9136 840 tempitem.wpn4 = 0;
9137 840 tempitem.wpn5 = 0;
9138 840 tempitem.wpn6 = 0;
9139 840 tempitem.wpn7 = 0;
9140 840 tempitem.wpn8 = 0;
9141 840 tempitem.wpn9 = 0;
9142 840 tempitem.wpn10 = 0;
9143 840 break;
9144 }
9145 case itype_heartring:
9146 {
9147 843 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9148 843 tempitem.misc3 = 0;
9149 843 tempitem.misc4 = 0;
9150 843 tempitem.misc5 = 0;
9151 843 tempitem.misc6 = 0;
9152 843 tempitem.misc7 = 0;
9153 843 tempitem.misc8 = 0;
9154 843 tempitem.misc9 = 0;
9155 843 tempitem.misc10 = 0;
9156 843 tempitem.wpn = 0;
9157 843 tempitem.wpn2 = 0;
9158 843 tempitem.wpn3 = 0;
9159 843 tempitem.wpn4 = 0;
9160 843 tempitem.wpn5 = 0;
9161 843 tempitem.wpn6 = 0;
9162 843 tempitem.wpn7 = 0;
9163 843 tempitem.wpn8 = 0;
9164 843 tempitem.wpn9 = 0;
9165 843 tempitem.wpn10 = 0;
9166 843 break;
9167 }
9168 case itype_magicring:
9169 {
9170 1128 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9171 1128 tempitem.misc3 = 0;
9172 1128 tempitem.misc4 = 0;
9173 1128 tempitem.misc5 = 0;
9174 1128 tempitem.misc6 = 0;
9175 1128 tempitem.misc7 = 0;
9176 1128 tempitem.misc8 = 0;
9177 1128 tempitem.misc9 = 0;
9178 1128 tempitem.misc10 = 0;
9179 1128 tempitem.wpn = 0;
9180 1128 tempitem.wpn2 = 0;
9181 1128 tempitem.wpn3 = 0;
9182 1128 tempitem.wpn4 = 0;
9183 1128 tempitem.wpn5 = 0;
9184 1128 tempitem.wpn6 = 0;
9185 1128 tempitem.wpn7 = 0;
9186 1128 tempitem.wpn8 = 0;
9187 1128 tempitem.wpn9 = 0;
9188 1128 tempitem.wpn10 = 0;
9189 1128 break;
9190 }
9191 case itype_spinscroll2:
9192 {
9193 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9194 279 tempitem.misc2 = 0;
9195 279 tempitem.misc3 = 0;
9196 279 tempitem.misc4 = 0;
9197 279 tempitem.misc5 = 0;
9198 279 tempitem.misc6 = 0;
9199 279 tempitem.misc7 = 0;
9200 279 tempitem.misc8 = 0;
9201 279 tempitem.misc9 = 0;
9202 279 tempitem.misc10 = 0;
9203 279 tempitem.wpn = 0;
9204 279 tempitem.wpn2 = 0;
9205 279 tempitem.wpn3 = 0;
9206 279 tempitem.wpn4 = 0;
9207 279 tempitem.wpn5 = 0;
9208 279 tempitem.wpn6 = 0;
9209 279 tempitem.wpn7 = 0;
9210 279 tempitem.wpn8 = 0;
9211 279 tempitem.wpn9 = 0;
9212 279 tempitem.wpn10 = 0;
9213 279 break;
9214 }
9215 case itype_quakescroll2:
9216 {
9217 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9218 279 tempitem.misc3 = 0;
9219 279 tempitem.misc4 = 0;
9220 279 tempitem.misc5 = 0;
9221 279 tempitem.misc6 = 0;
9222 279 tempitem.misc7 = 0;
9223 279 tempitem.misc8 = 0;
9224 279 tempitem.misc9 = 0;
9225 279 tempitem.misc10 = 0;
9226 279 tempitem.wpn = 0;
9227 279 tempitem.wpn2 = 0;
9228 279 tempitem.wpn3 = 0;
9229 279 tempitem.wpn4 = 0;
9230 279 tempitem.wpn5 = 0;
9231 279 tempitem.wpn6 = 0;
9232 279 tempitem.wpn7 = 0;
9233 279 tempitem.wpn8 = 0;
9234 279 tempitem.wpn9 = 0;
9235 279 tempitem.wpn10 = 0;
9236 279 break;
9237 }
9238 case itype_agony:
9239 {
9240 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9241 279 tempitem.misc2 = 0;
9242 279 tempitem.misc3 = 0;
9243 279 tempitem.misc4 = 0;
9244 279 tempitem.misc5 = 0;
9245 279 tempitem.misc6 = 0;
9246 279 tempitem.misc7 = 0;
9247 279 tempitem.misc8 = 0;
9248 279 tempitem.misc9 = 0;
9249 279 tempitem.misc10 = 0;
9250 279 tempitem.wpn = 0;
9251 279 tempitem.wpn2 = 0;
9252 279 tempitem.wpn3 = 0;
9253 279 tempitem.wpn4 = 0;
9254 279 tempitem.wpn5 = 0;
9255 279 tempitem.wpn6 = 0;
9256 279 tempitem.wpn7 = 0;
9257 279 tempitem.wpn8 = 0;
9258 279 tempitem.wpn9 = 0;
9259 279 tempitem.wpn10 = 0;
9260 279 break;
9261 }
9262 case itype_stompboots:
9263 {
9264 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9265 279 tempitem.misc1 = 0;
9266 279 tempitem.misc2 = 0;
9267 279 tempitem.misc3 = 0;
9268 279 tempitem.misc4 = 0;
9269 279 tempitem.misc5 = 0;
9270 279 tempitem.misc6 = 0;
9271 279 tempitem.misc7 = 0;
9272 279 tempitem.misc8 = 0;
9273 279 tempitem.misc9 = 0;
9274 279 tempitem.misc10 = 0;
9275 279 tempitem.wpn = 0;
9276 279 tempitem.wpn2 = 0;
9277 279 tempitem.wpn3 = 0;
9278 279 tempitem.wpn4 = 0;
9279 279 tempitem.wpn5 = 0;
9280 279 tempitem.wpn6 = 0;
9281 279 tempitem.wpn7 = 0;
9282 279 tempitem.wpn8 = 0;
9283 279 tempitem.wpn9 = 0;
9284 279 tempitem.wpn10 = 0;
9285 279 break;
9286 }
9287 case itype_whimsicalring:
9288 {
9289 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9290 279 tempitem.misc2 = 0;
9291 279 tempitem.misc3 = 0;
9292 279 tempitem.misc4 = 0;
9293 279 tempitem.misc5 = 0;
9294 279 tempitem.misc6 = 0;
9295 279 tempitem.misc7 = 0;
9296 279 tempitem.misc8 = 0;
9297 279 tempitem.misc9 = 0;
9298 279 tempitem.misc10 = 0;
9299 279 tempitem.wpn = 0;
9300 279 tempitem.wpn2 = 0;
9301 279 tempitem.wpn3 = 0;
9302 279 tempitem.wpn4 = 0;
9303 279 tempitem.wpn5 = 0;
9304 279 tempitem.wpn6 = 0;
9305 279 tempitem.wpn7 = 0;
9306 279 tempitem.wpn8 = 0;
9307 279 tempitem.wpn9 = 0;
9308 279 tempitem.wpn10 = 0;
9309 279 break;
9310 }
9311 case itype_perilring:
9312 {
9313 306 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9314 306 tempitem.misc2 = 0;
9315 306 tempitem.misc3 = 0;
9316 306 tempitem.misc4 = 0;
9317 306 tempitem.misc5 = 0;
9318 306 tempitem.misc6 = 0;
9319 306 tempitem.misc7 = 0;
9320 306 tempitem.misc8 = 0;
9321 306 tempitem.misc9 = 0;
9322 306 tempitem.misc10 = 0;
9323 306 tempitem.wpn = 0;
9324 306 tempitem.wpn2 = 0;
9325 306 tempitem.wpn3 = 0;
9326 306 tempitem.wpn4 = 0;
9327 306 tempitem.wpn5 = 0;
9328 306 tempitem.wpn6 = 0;
9329 306 tempitem.wpn7 = 0;
9330 306 tempitem.wpn8 = 0;
9331 306 tempitem.wpn9 = 0;
9332 306 tempitem.wpn10 = 0;
9333 306 break;
9334 }
9335 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9336 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9337 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9338 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9339 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9340 {
9341 10652 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9342 10652 tempitem.misc1 = 0;
9343 10652 tempitem.misc2 = 0;
9344 10652 tempitem.misc3 = 0;
9345 10652 tempitem.misc4 = 0;
9346 10652 tempitem.misc5 = 0;
9347 10652 tempitem.misc6 = 0;
9348 10652 tempitem.misc7 = 0;
9349 10652 tempitem.misc8 = 0;
9350 10652 tempitem.misc9 = 0;
9351 10652 tempitem.misc10 = 0;
9352 10652 tempitem.wpn = 0;
9353 10652 tempitem.wpn2 = 0;
9354 10652 tempitem.wpn3 = 0;
9355 10652 tempitem.wpn4 = 0;
9356 10652 tempitem.wpn5 = 0;
9357 10652 tempitem.wpn6 = 0;
9358 10652 tempitem.wpn7 = 0;
9359 10652 tempitem.wpn8 = 0;
9360 10652 tempitem.wpn9 = 0;
9361 10652 tempitem.wpn10 = 0;
9362 10652 break;
9363 }
9364 }
9365 72192 }
9366 //Port quest rules to items
9367
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version <= 31)
9368 {
9369
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 71897 times.
72192 if(tempitem.type == itype_bomb)
9370 {
9371
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 139 times.
295 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9372 139 else tempitem.flags &= ~ item_flag2;
9373 295 }
9374
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 71616 times.
71897 else if(tempitem.type == itype_sbomb)
9375 {
9376
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 123 times.
281 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9377 123 else tempitem.flags &= ~ item_flag2;
9378 281 }
9379
9380
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 70772 times.
71616 else if(tempitem.type == itype_brang)
9381 {
9382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9383 844 else tempitem.flags &= ~ item_flag4;
9384 844 }
9385
2/2
✓ Branch 0 taken 70475 times.
✓ Branch 1 taken 297 times.
70772 else if(tempitem.type == itype_wand)
9386 {
9387
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9388 279 else tempitem.flags &= ~ item_flag3;
9389 297 }
9390 72192 }
9391
9392 //Port quest rules to items
9393
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version <= 37)
9394 {
9395
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71910 times.
72192 if(tempitem.type == itype_flippers)
9396 {
9397
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 203 times.
282 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9398 203 else tempitem.flags &= ~ item_flag1;
9399 282 }
9400
2/2
✓ Branch 0 taken 54363 times.
✓ Branch 1 taken 17547 times.
71910 else if(tempitem.type == itype_sword)
9401 {
9402
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 17109 times.
17547 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9403 17109 else tempitem.flags &= ~ item_flag5;
9404 17547 }
9405
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 54066 times.
54363 else if(tempitem.type == itype_wand)
9406 {
9407
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 288 times.
297 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9408 288 else tempitem.flags &= ~ item_flag5;
9409 297 }
9410
4/4
✓ Branch 0 taken 53771 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 600 times.
✓ Branch 3 taken 53171 times.
54066 else if(tempitem.type == itype_book || tempitem.type == itype_candle)
9411 {
9412 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9413
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 520 times.
895 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9414 520 else tempitem.flags &= ~ item_flag3;
9415 895 }
9416 72192 }
9417
9418
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 38)
9419 {
9420
4/4
✓ Branch 0 taken 71348 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 560 times.
✓ Branch 3 taken 70788 times.
72192 if(tempitem.type == itype_brang || tempitem.type == itype_hookshot)
9421 {
9422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9423 1404 else tempitem.flags &= ~item_flag4;
9424
9425
2/2
✓ Branch 0 taken 673 times.
✓ Branch 1 taken 731 times.
1404 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9426 731 else tempitem.flags &= ~(item_flag5|item_flag6);
9427 1404 }
9428
2/2
✓ Branch 0 taken 69957 times.
✓ Branch 1 taken 831 times.
70788 else if(tempitem.type == itype_arrow)
9429 {
9430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 831 times.
831 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9431 831 else tempitem.flags &= ~item_flag4;
9432
9433
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 435 times.
831 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9434 435 else tempitem.flags |= item_flag2;
9435 831 }
9436 72192 }
9437
9438
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 39)
9439 {
9440
6/6
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 71618 times.
✓ Branch 3 taken 295 times.
✓ Branch 4 taken 600 times.
✓ Branch 5 taken 71018 times.
72192 if(tempitem.type == itype_divinefire || tempitem.type == itype_book || tempitem.type == itype_candle)
9441 {
9442
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1158 times.
1174 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9443 1158 else tempitem.flags &= ~item_flag5;
9444 1174 }
9445
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 70404 times.
71018 else if(tempitem.type == itype_potion)
9446 {
9447
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 452 times.
614 if(get_qr(qr_NONBUBBLEMEDICINE))
9448 {
9449 162 tempitem.flags &= ~(item_flag3|item_flag4);
9450 162 }
9451 else
9452 {
9453 452 tempitem.flags |= item_flag3;
9454
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 333 times.
452 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9455 333 else tempitem.flags &= ~item_flag4;
9456 }
9457 614 }
9458
2/2
✓ Branch 0 taken 69846 times.
✓ Branch 1 taken 558 times.
70404 else if(tempitem.type == itype_triforcepiece)
9459 {
9460
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 474 times.
558 if(get_qr(qr_NONBUBBLETRIFORCE))
9461 {
9462 84 tempitem.flags |= item_flag3;
9463
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9464 28 else tempitem.flags &= ~item_flag4;
9465 84 }
9466 else
9467 {
9468 474 tempitem.flags &= ~(item_flag3|item_flag4);
9469 }
9470 558 }
9471 72192 }
9472
9473
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 40)
9474 {
9475
4/4
✓ Branch 0 taken 71275 times.
✓ Branch 1 taken 917 times.
✓ Branch 2 taken 306 times.
✓ Branch 3 taken 70969 times.
72192 if(tempitem.type == itype_ring || tempitem.type == itype_perilring)
9476 {
9477
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 934 times.
1223 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9478 934 else tempitem.flags &= ~item_flag1;
9479 1223 }
9480
8/8
✓ Branch 0 taken 70369 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 52822 times.
✓ Branch 3 taken 17547 times.
✓ Branch 4 taken 52525 times.
✓ Branch 5 taken 297 times.
✓ Branch 6 taken 279 times.
✓ Branch 7 taken 52246 times.
70969 else if(tempitem.type == itype_candle || tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_cbyrna)
9481 {
9482
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18615 times.
18723 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9483 18615 else tempitem.flags &= ~item_flag8;
9484 18723 }
9485
6/6
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
✓ Branch 2 taken 54348 times.
✓ Branch 3 taken 297 times.
✓ Branch 4 taken 282 times.
✓ Branch 5 taken 54066 times.
72192 if(tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_hammer)
9486 {
9487
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 18048 times.
18126 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9488 18048 else tempitem.flags &= ~item_flag7;
9489 18126 }
9490
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 279 times.
54066 else if(tempitem.type == itype_cbyrna)
9491 {
9492 279 tempitem.flags |= item_flag7;
9493 279 }
9494 72192 }
9495
9496
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 41 )
9497 {
9498
2/2
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
72192 if(tempitem.type == itype_sword)
9499 {
9500
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 17311 times.
17547 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9501 17311 else tempitem.flags &= ~item_flag9;
9502
9503
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17119 times.
17547 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9504 17119 else tempitem.flags &= ~item_flag10;
9505 17547 }
9506 72192 }
9507
9508
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 42 )
9509 {
9510
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 71895 times.
72192 if(tempitem.type == itype_wand)
9511 {
9512
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9513 279 else tempitem.flags &= ~item_flag3;
9514
9515 297 tempitem.flags &= ~item_flag6;
9516 297 }
9517
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71613 times.
71895 else if(tempitem.type == itype_hammer)
9518 {
9519 282 tempitem.flags &= ~item_flag3;
9520 282 }
9521
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 71334 times.
71613 else if(tempitem.type == itype_cbyrna)
9522 {
9523 279 tempitem.flags |= item_flag3;
9524
9525 279 tempitem.flags &= ~item_flag6;
9526 279 }
9527
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 17547 times.
71334 else if(tempitem.type == itype_sword)
9528 {
9529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17547 times.
17547 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9530 17547 else tempitem.flags &= ~item_flag6;
9531 17547 }
9532 72192 }
9533
9534
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 43 )
9535 {
9536
2/2
✓ Branch 0 taken 71865 times.
✓ Branch 1 taken 327 times.
72192 if(tempitem.type == itype_whistle)
9537 {
9538
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 317 times.
327 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9539 317 else tempitem.flags &= ~item_flag3;
9540 327 }
9541 72192 }
9542
9543
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 45 )
9544 {
9545
2/2
✓ Branch 0 taken 71910 times.
✓ Branch 1 taken 282 times.
72192 if(tempitem.type == itype_flippers)
9546 {
9547 282 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9548 282 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9549 282 }
9550 72192 }
9551
9552
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 46 )
9553 {
9554
2/2
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
72192 if(tempitem.type == itype_raft)
9555 {
9556 279 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9557 279 }
9558 72192 }
9559
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if ( s_version < 34 ) //! set the default counter for older quests.
9560 {
9561
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 72076 times.
72192 if ( (tempitem.flags & item_rupee_magic) )
9562 {
9563 116 tempitem.cost_counter[0] = 1;
9564 116 }
9565 else
9566 {
9567
2/2
✓ Branch 0 taken 42496 times.
✓ Branch 1 taken 29580 times.
72076 if(get_qr(qr_ENABLEMAGIC))
9568 42496 tempitem.cost_counter[0] = 4;
9569 else
9570 {
9571 29580 tempitem.cost_amount[0] = 0;
9572 29580 tempitem.cost_counter[0] = -1;
9573 }
9574 }
9575 72192 }
9576
9577
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if ( s_version < 35 ) //new Lens of Truth flags
9578 {
9579
2/2
✓ Branch 0 taken 71937 times.
✓ Branch 1 taken 255 times.
72192 if ( tempitem.type == itype_lens )
9580 {
9581
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 10 times.
255 if ( get_qr(qr_RAFTLENS) )
9582 {
9583 10 tempitem.flags |= item_flag4;
9584 10 }
9585
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 166 times.
255 if ( get_qr(qr_LENSHINTS) )
9586 {
9587 166 tempitem.flags |= item_flag1;
9588 166 }
9589
2/2
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 13 times.
255 if ( get_qr(qr_LENSSEESENEMIES) )
9590 {
9591 13 tempitem.flags |= item_flag5;
9592 13 }
9593 255 }
9594 72192 }
9595
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9596 {
9597
2/2
✓ Branch 0 taken 577536 times.
✓ Branch 1 taken 72192 times.
649728 for ( int32_t q = 0; q < 8; q++ )
9598 {
9599 577536 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9600 577536 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9601 577536 tempitem.sprite_initiald[q] = 0;
9602 577536 }
9603 72192 tempitem.sprite_script = 0;
9604 72192 }
9605
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9606 {
9607 72192 tempitem.pickupflag = 0;
9608 72192 }
9609
9610
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 51 )
9611 {
9612
2/2
✓ Branch 0 taken 71592 times.
✓ Branch 1 taken 600 times.
72192 if( tempitem.type == itype_candle )
9613 {
9614 600 tempitem.misc4 = 50; //Step speed
9615 600 }
9616 72192 }
9617
9618
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if( s_version < 52 )
9619 {
9620
2/2
✓ Branch 0 taken 71334 times.
✓ Branch 1 taken 858 times.
72192 if( tempitem.type == itype_shield )
9621 858 tempitem.flags |= item_flag1; //'Block Front' flag
9622 72192 }
9623
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 72192 times.
127232 if(s_version < 53)
9624 {
9625
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 70785 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 281 times.
72192 switch(tempitem.type)
9626 {
9627 case itype_arrow:
9628 831 tempitem.cost_counter[1] = crARROWS;
9629 831 tempitem.cost_amount[1] = 1;
9630 831 break;
9631 case itype_bomb:
9632 295 tempitem.cost_counter[1] = crBOMBS;
9633 295 tempitem.cost_amount[1] = 1;
9634 295 break;
9635 case itype_sbomb:
9636 281 tempitem.cost_counter[1] = crSBOMBS;
9637 281 tempitem.cost_amount[1] = 1;
9638 281 break;
9639 default:
9640 70785 tempitem.cost_counter[1] = crNONE;
9641 70785 tempitem.cost_amount[1] = 0;
9642 70785 }
9643 72192 tempitem.magiccosttimer[1] = 0;
9644 72192 }
9645
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 75008 times.
127232 if( s_version < 54 )
9646 {
9647
2/2
✓ Branch 0 taken 74713 times.
✓ Branch 1 taken 295 times.
75008 if( tempitem.type == itype_flippers )
9648 295 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9649 75008 }
9650
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 75008 times.
127232 if(s_version < 55)
9651 {
9652
3/3
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 580 times.
✓ Branch 2 taken 73848 times.
75008 switch(tempitem.type)
9653 {
9654 case itype_spinscroll:
9655 case itype_quakescroll:
9656 580 tempitem.usesound2 = WAV_ZN1CHARGE;
9657 580 break;
9658 case itype_spinscroll2:
9659 case itype_quakescroll2:
9660 580 tempitem.usesound2 = WAV_ZN1CHARGE2;
9661 580 break;
9662 }
9663 75008 }
9664
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 75008 times.
127232 if(s_version < 56)
9665 {
9666
4/4
✓ Branch 0 taken 73786 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 306 times.
75008 switch(tempitem.type)
9667 {
9668 case itype_divinefire:
9669
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 11 times.
290 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9670
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 208 times.
290 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9671 290 tempitem.flags |= item_flag11; //Divine Fire
9672 290 break;
9673 case itype_candle:
9674
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 314 times.
626 SETFLAG(tempitem.flags, item_flag9, tempitem.level > 1); //Strong Fire
9675 626 tempitem.flags &= ~item_flag10; //Magic Fire
9676 626 tempitem.flags &= ~item_flag11; //Divine Fire
9677 626 break;
9678 case itype_book:
9679 306 tempitem.flags |= item_flag9; //Strong Fire
9680 306 tempitem.flags |= item_flag10; //Magic Fire
9681 306 tempitem.flags &= ~item_flag11; //Divine Fire
9682 306 break;
9683 }
9684 75008 }
9685
2/2
✓ Branch 0 taken 43264 times.
✓ Branch 1 taken 83968 times.
127232 if (s_version < 61)
9686 {
9687
2/2
✓ Branch 0 taken 65566 times.
✓ Branch 1 taken 18402 times.
83968 switch (tempitem.type)
9688 {
9689 case itype_sword:
9690 18402 tempitem.usesound2 = WAV_BEAM;
9691 18402 break;
9692 }
9693 83968 }
9694
9695
9696
2/2
✓ Branch 0 taken 10988 times.
✓ Branch 1 taken 116244 times.
127232 if(tempitem.level==0) // Always do this
9697 10988 tempitem.level=1;
9698
9699 127232 itemsbuf[i] = tempitem;
9700 127232 }
9701
9702 497 return 0;
9703 498 }
9704
9705 static bool did_init_def_items = false;
9706 254330 void init_def_items()
9707 {
9708
2/2
✓ Branch 0 taken 253947 times.
✓ Branch 1 taken 383 times.
254330 if(did_init_def_items) return;
9709 383 did_init_def_items = true;
9710 383 default_items[3].cost_counter[1] = crBOMBS;
9711 383 default_items[13].cost_counter[1] = crARROWS;
9712 383 default_items[14].cost_counter[1] = crARROWS;
9713 383 default_items[48].cost_counter[1] = crSBOMBS;
9714 383 default_items[57].cost_counter[1] = crARROWS;
9715 254330 }
9716 254330 void reset_itembuf(itemdata *item, int32_t id)
9717 {
9718 254330 init_def_items();
9719
2/2
✓ Branch 0 taken 107011 times.
✓ Branch 1 taken 147319 times.
254330 if(id<iLast)
9720 {
9721 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9722 147319 word tile = item->tile;
9723 147319 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9724 147319 int32_t ltm = item->ltm;
9725
9726 147319 *item = default_items[id];
9727 147319 item->tile = tile;
9728 147319 item->misc_flags = miscs;
9729 147319 item->csets = cset;
9730 147319 item->frames = frames;
9731 147319 item->speed = speed;
9732 147319 item->delay = delay;
9733 147319 item->ltm = ltm;
9734 147319 }
9735 254330 }
9736
9737 104448 void reset_itemname(int32_t id)
9738 {
9739 104448 sprintf(item_string[id],"zz%03d",id);
9740
9741
2/2
✓ Branch 0 taken 46104 times.
✓ Branch 1 taken 58344 times.
104448 if(id < iLast)
9742 58344 strcpy(item_string[id],old_item_string[id]);
9743 104448 }
9744
9745 498 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9746 {
9747
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9748
9749 498 word weapons_to_read=MAXWPNS;
9750 int32_t dummy;
9751 byte padding;
9752 wpndata tempweapon;
9753 498 word s_version=0;
9754
9755
9756
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 6 times.
498 if(Header->zelda_version < 0x186)
9757 {
9758 6 weapons_to_read=64;
9759 6 }
9760
9761
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 6 times.
498 if(Header->zelda_version < 0x185)
9762 {
9763 6 weapons_to_read=32;
9764 6 }
9765
9766
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 474 times.
498 if(Header->zelda_version > 0x192)
9767 {
9768 474 weapons_to_read=0;
9769
9770 //section version info
9771
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&s_version,f))
9772 {
9773 return qe_invalid;
9774 }
9775
9776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (s_version > V_WEAPONS)
9777 return qe_version;
9778
9779 474 FFCore.quest_format[vWeaponSprites] = s_version;
9780
9781
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!read_deprecated_section_cversion(f))
9782 {
9783 return qe_invalid;
9784 }
9785
9786 //section size
9787
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
9788 {
9789 return qe_invalid;
9790 }
9791
9792 //finally... section data
9793
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&weapons_to_read,f))
9794 {
9795 return qe_invalid;
9796 }
9797
9798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (weapons_to_read > MAXWPNS)
9799 {
9800 return qe_invalid;
9801 }
9802 474 }
9803
9804
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 83 times.
498 if(s_version>2)
9805 {
9806
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i=0; i<weapons_to_read; i++)
9807 {
9808 char tempname[64];
9809
9810
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if(!pfread(tempname, 64, f))
9811 {
9812 return qe_invalid;
9813 }
9814
9815 106240 weapon_string[i][0] = '\0';
9816 106240 strncat(weapon_string[i], tempname, 64 - 1);
9817 106240 }
9818
9819
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version<4)
9820 {
9821 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9822 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9823 }
9824
9825
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version<5)
9826 {
9827 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9828 }
9829
9830 /*
9831 if (s_version<6)
9832 {
9833 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9834 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9835 }
9836 */
9837 415 }
9838
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9839 {
9840
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9841 20992 reset_weaponname(i);
9842 82 }
9843
9844
2/2
✓ Branch 0 taken 115052 times.
✓ Branch 1 taken 498 times.
115550 for(int32_t i=0; i<weapons_to_read; i++)
9845 {
9846 115052 word oldtile = 0;
9847
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 61292 times.
115052 if (s_version < 8)
9848 {
9849
1/2
✓ Branch 0 taken 61292 times.
✗ Branch 1 not taken.
61292 if (!p_igetw(&oldtile, f))
9850 return qe_invalid;
9851 61292 }
9852
9853
1/2
✓ Branch 0 taken 115052 times.
✗ Branch 1 not taken.
115052 if(!p_getc(&tempweapon.misc,f))
9854 {
9855 return qe_invalid;
9856 }
9857
9858
1/2
✓ Branch 0 taken 115052 times.
✗ Branch 1 not taken.
115052 if(!p_getc(&tempweapon.csets,f))
9859 {
9860 return qe_invalid;
9861 }
9862
9863
1/2
✓ Branch 0 taken 115052 times.
✗ Branch 1 not taken.
115052 if(!p_getc(&tempweapon.frames,f))
9864 {
9865 return qe_invalid;
9866 }
9867
9868
1/2
✓ Branch 0 taken 115052 times.
✗ Branch 1 not taken.
115052 if(!p_getc(&tempweapon.speed,f))
9869 {
9870 return qe_invalid;
9871 }
9872
9873
1/2
✓ Branch 0 taken 115052 times.
✗ Branch 1 not taken.
115052 if(!p_getc(&tempweapon.type,f))
9874 {
9875 return qe_invalid;
9876 }
9877
9878
2/2
✓ Branch 0 taken 60012 times.
✓ Branch 1 taken 55040 times.
115052 if ( s_version >= 7 )
9879 {
9880
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetw(&tempweapon.script,f))
9881 {
9882 return qe_invalid;
9883 }
9884
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_igetl(&tempweapon.tile,f))
9885 {
9886 return qe_invalid;
9887 }
9888 55040 }
9889
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 60012 times.
115052 if ( s_version < 7 )
9890 {
9891 60012 tempweapon.tile = oldtile;
9892 60012 }
9893
9894
2/2
✓ Branch 0 taken 110252 times.
✓ Branch 1 taken 4800 times.
115052 if(Header->zelda_version < 0x193)
9895 {
9896
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9897 {
9898 return qe_invalid;
9899 }
9900 4800 }
9901
9902
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 8812 times.
115052 if(s_version < 6)
9903 {
9904
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9905 {
9906 18 tempweapon.misc |= WF_BEHIND;
9907 18 }
9908 else
9909 8794 tempweapon.misc &= ~WF_BEHIND;
9910 8812 }
9911
9912
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 114796 times.
115052 if (!should_skip)
9913 114796 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9914 115052 }
9915
9916
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 497 times.
498 if (should_skip)
9917 1 return 0;
9918
9919
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
497 if(s_version<2)
9920 {
9921 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9922 82 }
9923
9924
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
497 if(s_version<5)
9925 {
9926 82 wpnsbuf[iwQuarterHearts].tile=1;
9927 82 wpnsbuf[iwQuarterHearts].csets=1;
9928 82 }
9929
9930
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 if(Header->zelda_version < 0x176)
9931 {
9932 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9933 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9934 itemsbuf[iMisc1].clear();
9935 itemsbuf[iMisc2].clear();
9936 }
9937
9938
3/4
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
502 if((Header->zelda_version < 0x192)||
9939
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 474 times.
479 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9940 {
9941 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9942 18 }
9943
9944
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 if((Header->zelda_version < 0x210))
9945 {
9946 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9947 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9948 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9949 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9950 23 }
9951
9952 497 return 0;
9953 498 }
9954
9955 224965 static void guy_update_firesfx(guydata& tempguy)
9956 {
9957 224965 tempguy.firesfx = 0;
9958
2/2
✓ Branch 0 taken 6559 times.
✓ Branch 1 taken 218406 times.
224965 if (tempguy.type == eeWIZZ)
9959 {
9960
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 989 times.
✓ Branch 2 taken 4010 times.
✓ Branch 3 taken 844 times.
✓ Branch 4 taken 716 times.
6559 switch (tempguy.attributes[1])
9961 {
9962 case 0: // normal weapon
9963 4010 tempguy.firesfx = WAV_WAND;
9964 4010 break;
9965 case 1: // 8 shots
9966
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 762 times.
844 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9967 else
9968 {
9969
3/8
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
762 switch (tempguy.weapon)
9970 {
9971 case ewFireTrail:
9972 case ewFlame:
9973 case ewFlame2Trail:
9974 case ewFlame2:
9975 658 tempguy.firesfx = WAV_FIRE;
9976 658 break;
9977 case ewWind:
9978 case ewMagic:
9979 88 tempguy.firesfx = WAV_WAND;
9980 88 break;
9981 case ewIce:
9982 tempguy.firesfx = WAV_ZN1ICE;
9983 break;
9984 case ewRock:
9985 tempguy.firesfx = WAV_ZN1ROCK;
9986 break;
9987 case ewFireball2:
9988 case ewFireball:
9989 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9990 16 break;
9991 case ewBrang:
9992 tempguy.firesfx = WAV_BRANG;
9993 break;
9994 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9995 tempguy.firesfx = WAV_BOMB;
9996 break;
9997 default:
9998 tempguy.firesfx = 0;
9999 break;
10000 }
10001 762 break;
10002 }
10003 case 2: // Summon
10004 1071 tempguy.firesfx = WAV_FIRE;
10005 1071 break;
10006 case 3: // Summon Layer
10007 716 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
10008 716 break;
10009 }
10010 6559 }
10011 else
10012 {
10013
6/6
✓ Branch 0 taken 164563 times.
✓ Branch 1 taken 53843 times.
✓ Branch 2 taken 42795 times.
✓ Branch 3 taken 207358 times.
✓ Branch 4 taken 48321 times.
✓ Branch 5 taken 48317 times.
218406 if ((tempguy.type == eeWALK || tempguy.type == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
10014 {
10015 96638 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
10016 96638 }
10017 else
10018 {
10019
7/8
✓ Branch 0 taken 9824 times.
✓ Branch 1 taken 2406 times.
✓ Branch 2 taken 1832 times.
✓ Branch 3 taken 13082 times.
✓ Branch 4 taken 173858 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4042 times.
✓ Branch 7 taken 2314 times.
207358 switch (tempguy.weapon)
10020 {
10021 case ewFireTrail:
10022 case ewFlame:
10023 case ewFlame2Trail:
10024 case ewFlame2:
10025 9824 tempguy.firesfx = WAV_FIRE;
10026 9824 break;
10027 case ewWind:
10028 case ewMagic:
10029 1832 tempguy.firesfx = WAV_WAND;
10030 1832 break;
10031 case ewIce:
10032 tempguy.firesfx = WAV_ZN1ICE;
10033 break;
10034 case ewRock:
10035 4042 tempguy.firesfx = WAV_ZN1ROCK;
10036 4042 break;
10037 case ewFireball2:
10038 case ewFireball:
10039 13082 tempguy.firesfx = WAV_ZN1FIREBALL;
10040 13082 break;
10041 case ewBrang:
10042 2314 tempguy.firesfx = WAV_BRANG;
10043 2314 break;
10044 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
10045 2406 tempguy.firesfx = WAV_BOMB;
10046 2406 break;
10047 default:
10048 173858 tempguy.firesfx = 0;
10049 173858 break;
10050 }
10051 }
10052 }
10053 213921 }
10054
10055 213921 static void guy_update_weaponflags(guydata& tempguy)
10056 {
10057 213921 tempguy.weap_data.unblockable = 0;
10058 213921 tempguy.weap_data.moveflags = move_none;
10059
4/4
✓ Branch 0 taken 207252 times.
✓ Branch 1 taken 6669 times.
✓ Branch 2 taken 3068 times.
✓ Branch 3 taken 204184 times.
213921 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
10060 9737 tempguy.weap_data.moveflags |= (move_obeys_grav | move_can_pitfall);
10061 213921 tempguy.weap_data.override_flags = 0;
10062 213921 tempguy.weap_data.hxofs = 0;
10063 213921 tempguy.weap_data.hyofs = 0;
10064 213921 tempguy.weap_data.hxsz = 0;
10065 213921 tempguy.weap_data.hysz = 0;
10066 213921 tempguy.weap_data.hzsz = 0;
10067 213921 tempguy.weap_data.xofs = 0;
10068 213921 tempguy.weap_data.yofs = 0;
10069 213921 tempguy.weap_data.tilew = 0;
10070 213921 tempguy.weap_data.tileh = 0;
10071
5/5
✓ Branch 0 taken 2559 times.
✓ Branch 1 taken 171846 times.
✓ Branch 2 taken 18879 times.
✓ Branch 3 taken 13098 times.
✓ Branch 4 taken 7539 times.
213921 switch (tempguy.weapon)
10072 {
10073 case ewFireball: case ewFireball2:
10074 13098 tempguy.weap_data.step = 1.75_zf;
10075 13098 break;
10076 case ewSword: case ewLitBomb: case ewLitSBomb:
10077 case ewRock: case ewMagic: case ewWind:
10078 18879 tempguy.weap_data.step = 3_zf;
10079 18879 break;
10080 case ewArrow:
10081 2559 tempguy.weap_data.step = 2_zf;
10082 2559 break;
10083 case ewFlame: case ewFlame2:
10084 7539 tempguy.weap_data.step = 1_zf;
10085 7539 break;
10086 default:
10087 171846 tempguy.weap_data.step = 0_zf;
10088 171846 break;
10089 }
10090
2/2
✓ Branch 0 taken 1069605 times.
✓ Branch 1 taken 213921 times.
1283526 for (int q = 0; q < WPNSPR_MAX; ++q)
10091 {
10092 1069605 tempguy.weap_data.burnsprs[q] = 0;
10093 1069605 tempguy.weap_data.light_rads[q] = 0;
10094 1069605 }
10095 213921 }
10096
10097 213921 static void guy_update_weaponspecialsfx(guydata& tempguy)
10098 {
10099
3/3
✓ Branch 0 taken 2314 times.
✓ Branch 1 taken 209146 times.
✓ Branch 2 taken 2461 times.
213921 switch (tempguy.weapon)
10100 {
10101 case ewBrang:
10102 2314 tempguy.specialsfx = WAV_BRANG;
10103 2314 break;
10104 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
10105 2461 tempguy.specialsfx = WAV_BOMB;
10106 2461 break;
10107 default:
10108 209146 tempguy.specialsfx = 0;
10109 209146 break;
10110 }
10111 213921 }
10112
10113 497 void init_guys(int32_t guyversion)
10114 {
10115
2/2
✓ Branch 0 taken 254464 times.
✓ Branch 1 taken 497 times.
254961 for(int32_t i=0; i<MAXGUYS; i++)
10116 {
10117 254464 guysbuf[i] = default_guys[0];
10118 254464 }
10119
10120
2/2
✓ Branch 0 taken 87969 times.
✓ Branch 1 taken 497 times.
88466 for(int32_t i=0; i<OLDMAXGUYS; i++)
10121 {
10122 87969 guysbuf[i] = default_guys[i];
10123
2/2
✓ Branch 0 taken 86975 times.
✓ Branch 1 taken 994 times.
87969 guysbuf[i].spr_shadow = (guysbuf[i].type==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
10124 87969 guysbuf[i].spr_death = iwDeath;
10125 87969 guysbuf[i].spr_spawn = iwSpawn;
10126 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
10127
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 73455 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
87969 if(guyversion<=3 && i==ePATRABS)
10128 {
10129 82 guysbuf[i].bosspal=spDIG;
10130 82 guysbuf[i].cset=14;
10131 82 guysbuf[i].attributes[8] = 14;
10132 82 }
10133
10134
2/2
✓ Branch 0 taken 73455 times.
✓ Branch 1 taken 14514 times.
87969 if(guyversion<=3)
10135 {
10136 // Rope/Ghini Flash rules
10137
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
10138 {
10139
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
10140 {
10141 59 guysbuf[i].flags &= ~guy_flashing;
10142 59 }
10143 10443 }
10144
10145
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
10146 {
10147
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
10148 {
10149 72 guysbuf[i].flags &= ~guy_flashing;
10150 72 }
10151 2124 }
10152
10153
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
10154 {
10155
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
10156 {
10157 4 guysbuf[i].flags |= guy_blinking;
10158 4 }
10159
10160
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
10161 {
10162 38 guysbuf[i].flags |= guy_transparent;
10163 38 }
10164 82 }
10165
10166
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
10167 {
10168 164 guysbuf[i].flags |= guy_ignore_kill_all;
10169 164 }
10170 14514 }
10171
10172 // Darknut fix
10173
10/10
✓ Branch 0 taken 87472 times.
✓ Branch 1 taken 497 times.
✓ Branch 2 taken 86975 times.
✓ Branch 3 taken 497 times.
✓ Branch 4 taken 86478 times.
✓ Branch 5 taken 497 times.
✓ Branch 6 taken 85981 times.
✓ Branch 7 taken 497 times.
✓ Branch 8 taken 497 times.
✓ Branch 9 taken 85484 times.
87969 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
10174 {
10175
2/2
✓ Branch 0 taken 2075 times.
✓ Branch 1 taken 410 times.
2485 if(get_qr(qr_NEWENEMYTILES))
10176 {
10177 2075 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
10178 2075 guysbuf[i].s_width=guysbuf[i].e_width;
10179 2075 guysbuf[i].s_height=guysbuf[i].e_height;
10180 2075 }
10181 410 else guysbuf[i].s_tile=860;
10182
10183
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2165 times.
2485 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
10184 2165 guysbuf[i].flags &= ~guy_bkshield;
10185 else
10186 320 guysbuf[i].flags |= guy_bkshield;
10187 2485 }
10188
10189
4/4
✓ Branch 0 taken 87472 times.
✓ Branch 1 taken 497 times.
✓ Branch 2 taken 87919 times.
✓ Branch 3 taken 50 times.
87969 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
10190 {
10191 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
10192 50 }
10193
10194 87969 guy_update_firesfx(guysbuf[i]);
10195 87969 guy_update_weaponflags(guysbuf[i]);
10196 87969 guy_update_weaponspecialsfx(guysbuf[i]);
10197 87969 }
10198 497 }
10199
10200 20992 void reset_weaponname(int32_t i)
10201 {
10202
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
10203 {
10204 7216 strcpy(weapon_string[i],old_weapon_string[i]);
10205 7216 }
10206 else
10207 13776 sprintf(weapon_string[i],"zz%03d",i);
10208 20992 }
10209
10210 497 void init_item_drop_sets()
10211 {
10212
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
10213 {
10214 // item_drop_sets[i] = default_item_drop_sets[0];
10215 127232 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
10216 127232 }
10217
10218
2/2
✓ Branch 0 taken 6461 times.
✓ Branch 1 taken 497 times.
6958 for(int32_t i=0; i<isMAX; i++)
10219 {
10220 6461 item_drop_sets[i] = default_item_drop_sets[i];
10221
10222 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
10223
2/2
✓ Branch 0 taken 64610 times.
✓ Branch 1 taken 6461 times.
71071 for(int32_t j=0; j<10; ++j)
10224 {
10225 64610 int32_t it = item_drop_sets[i].item[j];
10226
10227
3/4
✓ Branch 0 taken 45448 times.
✓ Branch 1 taken 19162 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2934 times.
64610 if((itemsbuf[it].type == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
10228
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 42514 times.
45448 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
10229 {
10230 2934 item_drop_sets[i].chance[j+1]=0;
10231 2934 }
10232
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 59688 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1844 times.
61676 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
10233 {
10234 144 item_drop_sets[i].chance[j+1]=0;
10235 144 }
10236
10237 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
10238
2/2
✓ Branch 0 taken 64586 times.
✓ Branch 1 taken 24 times.
64610 if(itemsbuf[it].type == itype_misc)
10239 {
10240 // If a non-gameplay item was selected, then item drop was aborted.
10241 // Reflect this by increasing the 'Nothing' chance accordingly.
10242 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
10243 24 item_drop_sets[i].chance[j+1]=0;
10244 24 }
10245 64610 }
10246 6461 }
10247 497 }
10248
10249 497 void init_favorites()
10250 {
10251
2/2
✓ Branch 0 taken 626220 times.
✓ Branch 1 taken 497 times.
626717 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
10252 {
10253 626220 favorite_combos[i]=-1;
10254 626220 }
10255 497 }
10256
10257 784 int32_t init_combo_classes()
10258 {
10259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
10260
2/2
✓ Branch 0 taken 144256 times.
✓ Branch 1 taken 784 times.
145040 for(int32_t i=0; i<cMAX; i++)
10261 {
10262 144256 combo_class_buf[i] = default_combo_classes[i];
10263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144256 times.
144256 if ( char const* nm = zi->getComboTypeName(i) )
10264 {
10265 144256 size_t len = strlen(nm);
10266
2/2
✓ Branch 0 taken 9232384 times.
✓ Branch 1 taken 144256 times.
9376640 for ( size_t q = 0; q < 64; q++ )
10267 {
10268
2/2
✓ Branch 0 taken 2114448 times.
✓ Branch 1 taken 7117936 times.
9232384 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
10269 9232384 }
10270 144256 }
10271 144256 }
10272
10273 784 return 0;
10274 }
10275
10276 305 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
10277 {
10278
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 259 times.
305 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
10279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if (should_skip) return 0;
10280
10281
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 assert(v_herosprites < 6);
10282
10283 305 zinit.hero_swim_speed=67; //default
10284 305 setupherotiles(zinit.heroAnimationStyle);
10285 305 setupherodefenses();
10286 305 setupherooffsets();
10287
10288
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 200 times.
305 if(v_herosprites>=0)
10289 {
10290 word tile, tile2;
10291 byte flip, extend, dummy_byte;
10292
10293
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10294 {
10295
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10296 {
10297 return qe_invalid;
10298 }
10299
10300
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10301 {
10302 return qe_invalid;
10303 }
10304
10305
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10306 {
10307 return qe_invalid;
10308 }
10309
10310 800 walkspr[i][spr_tile]=(int32_t)tile;
10311 800 walkspr[i][spr_flip]=(int32_t)flip;
10312 800 walkspr[i][spr_extend]=(int32_t)extend;
10313 800 }
10314
10315
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10316 {
10317
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10318 {
10319 return qe_invalid;
10320 }
10321
10322
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10323 {
10324 return qe_invalid;
10325 }
10326
10327
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10328 {
10329 return qe_invalid;
10330 }
10331
10332 800 stabspr[i][spr_tile]=(int32_t)tile;
10333 800 stabspr[i][spr_flip]=(int32_t)flip;
10334 800 stabspr[i][spr_extend]=(int32_t)extend;
10335 800 }
10336
10337
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10338 {
10339
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10340 {
10341 return qe_invalid;
10342 }
10343
10344
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10345 {
10346 return qe_invalid;
10347 }
10348
10349
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10350 {
10351 return qe_invalid;
10352 }
10353
10354 800 slashspr[i][spr_tile]=(int32_t)tile;
10355 800 slashspr[i][spr_flip]=(int32_t)flip;
10356 800 slashspr[i][spr_extend]=(int32_t)extend;
10357 800 }
10358
10359
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10360 {
10361
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10362 {
10363 return qe_invalid;
10364 }
10365
10366
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10367 {
10368 return qe_invalid;
10369 }
10370
10371
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10372 {
10373 return qe_invalid;
10374 }
10375
10376 800 floatspr[i][spr_tile]=(int32_t)tile;
10377 800 floatspr[i][spr_flip]=(int32_t)flip;
10378 800 floatspr[i][spr_extend]=(int32_t)extend;
10379 800 }
10380
10381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>1)
10382 {
10383
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10384 {
10385
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10386 {
10387 return qe_invalid;
10388 }
10389
10390
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10391 {
10392 return qe_invalid;
10393 }
10394
10395
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10396 {
10397 return qe_invalid;
10398 }
10399
10400 800 swimspr[i][spr_tile]=(int32_t)tile;
10401 800 swimspr[i][spr_flip]=(int32_t)flip;
10402 800 swimspr[i][spr_extend]=(int32_t)extend;
10403 800 }
10404 200 }
10405
10406
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10407 {
10408
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10409 {
10410 return qe_invalid;
10411 }
10412
10413
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10414 {
10415 return qe_invalid;
10416 }
10417
10418
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10419 {
10420 return qe_invalid;
10421 }
10422
10423 800 divespr[i][spr_tile]=(int32_t)tile;
10424 800 divespr[i][spr_flip]=(int32_t)flip;
10425 800 divespr[i][spr_extend]=(int32_t)extend;
10426 800 }
10427
10428
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10429 {
10430
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10431 {
10432 return qe_invalid;
10433 }
10434
10435
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10436 {
10437 return qe_invalid;
10438 }
10439
10440
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10441 {
10442 return qe_invalid;
10443 }
10444
10445 800 poundspr[i][spr_tile]=(int32_t)tile;
10446 800 poundspr[i][spr_flip]=(int32_t)flip;
10447 800 poundspr[i][spr_extend]=(int32_t)extend;
10448 800 }
10449
10450
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&tile,f))
10451 {
10452 return qe_invalid;
10453 }
10454
10455 200 flip=0;
10456
10457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>0)
10458 {
10459
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&flip,f))
10460 {
10461 return qe_invalid;
10462 }
10463 200 }
10464
10465
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&extend,f))
10466 {
10467 return qe_invalid;
10468 }
10469
10470 200 castingspr[spr_tile]=(int32_t)tile;
10471 200 castingspr[spr_flip]=(int32_t)flip;
10472 200 castingspr[spr_extend]=(int32_t)extend;
10473
10474
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(v_herosprites>0)
10475 {
10476 200 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10477
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 200 times.
600 for(int32_t i=0; i<2; i++)
10478 {
10479
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 400 times.
1200 for(int32_t j=0; j<num_holdsprs; j++)
10480 {
10481
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10482 {
10483 return qe_invalid;
10484 }
10485
10486
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10487 {
10488 return qe_invalid;
10489 }
10490
10491
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10492 {
10493 return qe_invalid;
10494 }
10495
10496 800 holdspr[i][j][spr_tile]=(int32_t)tile;
10497 800 holdspr[i][j][spr_flip]=(int32_t)flip;
10498 800 holdspr[i][j][spr_extend]=(int32_t)extend;
10499 800 }
10500 400 }
10501 200 }
10502 else
10503 {
10504 for(int32_t i=0; i<2; i++)
10505 {
10506 if(!p_igetw(&tile,f))
10507 {
10508 return qe_invalid;
10509 }
10510
10511 if(!p_igetw(&tile2,f))
10512 {
10513 return qe_invalid;
10514 }
10515
10516 if(!p_getc(&extend,f))
10517 {
10518 return qe_invalid;
10519 }
10520
10521 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10522 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10523 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10524 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10525 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10526 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10527 }
10528 }
10529
10530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>2)
10531 {
10532
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10533 {
10534
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10535 {
10536 return qe_invalid;
10537 }
10538
10539
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10540 {
10541 return qe_invalid;
10542 }
10543
10544
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10545 {
10546 return qe_invalid;
10547 }
10548
10549 800 jumpspr[i][spr_tile]=(int32_t)tile;
10550 800 jumpspr[i][spr_flip]=(int32_t)flip;
10551 800 jumpspr[i][spr_extend]=(int32_t)extend;
10552 800 }
10553 200 }
10554
10555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>3)
10556 {
10557
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10558 {
10559
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10560 {
10561 return qe_invalid;
10562 }
10563
10564
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10565 {
10566 return qe_invalid;
10567 }
10568
10569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(!p_getc(&extend,f))
10570 {
10571 return qe_invalid;
10572 }
10573
10574 800 chargespr[i][spr_tile]=(int32_t)tile;
10575 800 chargespr[i][spr_flip]=(int32_t)flip;
10576 800 chargespr[i][spr_extend]=(int32_t)extend;
10577 800 }
10578 200 }
10579
10580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>4)
10581 {
10582
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&dummy_byte,f))
10583 {
10584 return qe_invalid;
10585 }
10586
10587 200 zinit.hero_swim_speed=(byte)dummy_byte;
10588 200 }
10589
10590 200 memset(frozenspr, 0, sizeof(frozenspr));
10591 200 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10592 200 memset(onfirespr, 0, sizeof(onfirespr));
10593 200 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10594 200 memset(diggingspr, 0, sizeof(diggingspr));
10595 200 memset(usingrodspr, 0, sizeof(usingrodspr));
10596 200 memset(usingcanespr, 0, sizeof(usingcanespr));
10597 200 memset(pushingspr, 0, sizeof(pushingspr));
10598 200 memset(liftingspr, 0, sizeof(liftingspr));
10599 200 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10600 200 memset(stunnedspr, 0, sizeof(stunnedspr));
10601 200 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10602 200 memset(fallingspr, 0, sizeof(fallingspr));
10603 200 memset(shockedspr, 0, sizeof(shockedspr));
10604 200 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10605 200 memset(pullswordspr, 0, sizeof(pullswordspr));
10606 200 memset(readingspr, 0, sizeof(readingspr));
10607 200 memset(slash180spr, 0, sizeof(slash180spr));
10608 200 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10609 200 memset(dashspr, 0, sizeof(dashspr));
10610 200 memset(bonkspr, 0, sizeof(bonkspr));
10611 200 memset(medallionsprs, 0, sizeof(medallionsprs));
10612 200 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10613 200 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10614
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t q = 0; q < 4; ++q)
10615 {
10616
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 800 times.
3200 for(int32_t p = 0; p < 3; ++p)
10617 {
10618 2400 drowningspr[q][p] = divespr[q][p];
10619 2400 drowning_lavaspr[q][p] = divespr[q][p];
10620 2400 }
10621 800 }
10622 200 memset(sideswimspr, 0, sizeof(sideswimspr));
10623 200 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10624 200 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10625 200 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10626 200 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10627 200 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10628 200 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10629 200 }
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if(FFCore.quest_format[vInitData] < 34)
10632 {
10633 305 bool fastswim = zinit.hero_swim_speed > 60;
10634 // '2/3' or '1/2'
10635 305 zinit.hero_swim_mult = fastswim ? 2 : 1;
10636 305 zinit.hero_swim_div = fastswim ? 3 : 2;
10637 305 }
10638 305 return 0;
10639 305 }
10640
10641 36550 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10642 {
10643 36550 arr[spr_tile] = tile;
10644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36550 times.
36550 arr[spr_flip] = (flip > 3 ? 0 : flip);
10645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36550 times.
36550 arr[spr_extend] = (ext > 2 ? 0 : ext);
10646 36550 }
10647 //Used to read the player sprites as int32_t, not word.
10648 215 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10649 {
10650 215 zinit.hero_swim_speed=67; //default
10651 215 setupherotiles(zinit.heroAnimationStyle);
10652 215 setupherodefenses();
10653 215 setupherooffsets();
10654
10655 int32_t tile, tile2;
10656 byte flip, extend, dummy_byte;
10657
10658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>=0)
10659 {
10660
10661
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10662 {
10663
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10664 {
10665 return qe_invalid;
10666 }
10667
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10669 {
10670 return qe_invalid;
10671 }
10672
10673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10674 {
10675 return qe_invalid;
10676 }
10677
10678 860 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10679 860 }
10680
10681
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10682 {
10683
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10684 {
10685 return qe_invalid;
10686 }
10687
10688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10689 {
10690 return qe_invalid;
10691 }
10692
10693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10694 {
10695 return qe_invalid;
10696 }
10697
10698 860 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10699 860 }
10700
10701
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10702 {
10703
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10704 {
10705 return qe_invalid;
10706 }
10707
10708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10709 {
10710 return qe_invalid;
10711 }
10712
10713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10714 {
10715 return qe_invalid;
10716 }
10717
10718 860 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10719 860 }
10720
10721
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10722 {
10723
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10724 {
10725 return qe_invalid;
10726 }
10727
10728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10729 {
10730 return qe_invalid;
10731 }
10732
10733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10734 {
10735 return qe_invalid;
10736 }
10737
10738 860 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10739 860 }
10740
10741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>1)
10742 {
10743
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10744 {
10745
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10746 {
10747 return qe_invalid;
10748 }
10749
10750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10751 {
10752 return qe_invalid;
10753 }
10754
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10756 {
10757 return qe_invalid;
10758 }
10759
10760 860 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10761 860 }
10762 215 }
10763
10764
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10765 {
10766
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10767 {
10768 return qe_invalid;
10769 }
10770
10771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10772 {
10773 return qe_invalid;
10774 }
10775
10776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10777 {
10778 return qe_invalid;
10779 }
10780
10781 860 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10782 860 }
10783
10784
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10785 {
10786
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10787 {
10788 return qe_invalid;
10789 }
10790
10791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10792 {
10793 return qe_invalid;
10794 }
10795
10796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10797 {
10798 return qe_invalid;
10799 }
10800
10801 860 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10802 860 }
10803
10804
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_igetl(&tile,f))
10805 {
10806 return qe_invalid;
10807 }
10808
10809 215 flip=0;
10810
10811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>0)
10812 {
10813
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_getc(&flip,f))
10814 {
10815 return qe_invalid;
10816 }
10817 215 }
10818
10819
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_getc(&extend,f))
10820 {
10821 return qe_invalid;
10822 }
10823
10824 215 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10825
10826
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(v_herosprites>0)
10827 {
10828 215 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10829
2/2
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 215 times.
645 for(int32_t i=0; i<2; i++)
10830 {
10831
2/2
✓ Branch 0 taken 1290 times.
✓ Branch 1 taken 430 times.
1720 for(int32_t j=0; j<num_holdsprs; j++)
10832 {
10833
1/2
✓ Branch 0 taken 1290 times.
✗ Branch 1 not taken.
1290 if(!p_igetl(&tile,f))
10834 {
10835 return qe_invalid;
10836 }
10837
10838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1290 times.
1290 if(!p_getc(&flip,f))
10839 {
10840 return qe_invalid;
10841 }
10842
10843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1290 times.
1290 if(!p_getc(&extend,f))
10844 {
10845 return qe_invalid;
10846 }
10847
10848 1290 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10849 1290 }
10850 430 }
10851 215 }
10852 else
10853 {
10854 for(int32_t i=0; i<2; i++)
10855 {
10856 if(!p_igetl(&tile,f))
10857 {
10858 return qe_invalid;
10859 }
10860
10861 if(!p_igetl(&tile2,f))
10862 {
10863 return qe_invalid;
10864 }
10865
10866 if(!p_getc(&extend,f))
10867 {
10868 return qe_invalid;
10869 }
10870
10871 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10872 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10873 }
10874 }
10875
10876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>2)
10877 {
10878
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10879 {
10880
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10881 {
10882 return qe_invalid;
10883 }
10884
10885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10886 {
10887 return qe_invalid;
10888 }
10889
10890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10891 {
10892 return qe_invalid;
10893 }
10894
10895 860 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10896 860 }
10897 215 }
10898
10899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>3)
10900 {
10901
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t i=0; i<4; i++)
10902 {
10903
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10904 {
10905 return qe_invalid;
10906 }
10907
10908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10909 {
10910 return qe_invalid;
10911 }
10912
10913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10914 {
10915 return qe_invalid;
10916 }
10917
10918 860 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10919 860 }
10920 215 }
10921
10922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(v_herosprites>4)
10923 {
10924
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_getc(&dummy_byte,f))
10925 {
10926 return qe_invalid;
10927 }
10928
10929 215 zinit.hero_swim_speed=(byte)dummy_byte;
10930 215 }
10931
10932
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(v_herosprites>6)
10933 {
10934
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10935 {
10936
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10937 return qe_invalid;
10938
10939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10940 return qe_invalid;
10941
10942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10943 return qe_invalid;
10944
10945 860 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10946 860 }
10947
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10948 {
10949
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10950 return qe_invalid;
10951
10952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10953 return qe_invalid;
10954
10955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10956 return qe_invalid;
10957
10958 860 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10959 860 }
10960
10961
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10962 {
10963
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10964 return qe_invalid;
10965
10966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10967 return qe_invalid;
10968
10969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10970 return qe_invalid;
10971
10972 860 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10973 860 }
10974
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10975 {
10976
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10977 return qe_invalid;
10978
10979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10980 return qe_invalid;
10981
10982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10983 return qe_invalid;
10984
10985 860 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10986 860 }
10987
10988
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
10989 {
10990
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
10991 return qe_invalid;
10992
10993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
10994 return qe_invalid;
10995
10996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
10997 return qe_invalid;
10998
10999 860 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11000 860 }
11001
11002
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11003 {
11004
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11005 return qe_invalid;
11006
11007
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11008 return qe_invalid;
11009
11010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11011 return qe_invalid;
11012
11013 860 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11014 860 }
11015
11016
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11017 {
11018
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11019 return qe_invalid;
11020
11021
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11022 return qe_invalid;
11023
11024
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11025 return qe_invalid;
11026
11027 860 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11028 860 }
11029
11030
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11031 {
11032
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11033 return qe_invalid;
11034
11035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11036 return qe_invalid;
11037
11038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11039 return qe_invalid;
11040
11041 860 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11042 860 }
11043
11044
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11045 {
11046
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11047 return qe_invalid;
11048
11049
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11050 return qe_invalid;
11051
11052
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11053 return qe_invalid;
11054
11055 860 byte frames = 0;
11056
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 840 times.
860 if(v_herosprites > 15)
11057 {
11058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 840 times.
840 if(!p_getc(&frames,f))
11059 return qe_invalid;
11060 840 }
11061
11062 860 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11063 860 liftingspr[q][spr_frames] = frames;
11064 860 }
11065
11066
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11067 {
11068
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11069 return qe_invalid;
11070
11071
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11072 return qe_invalid;
11073
11074
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11075 return qe_invalid;
11076
11077 860 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11078 860 }
11079
11080
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11081 {
11082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_igetl(&tile,f))
11083 return qe_invalid;
11084
11085
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11086 return qe_invalid;
11087
11088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11089 return qe_invalid;
11090
11091 860 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11092 860 }
11093
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11094 {
11095
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11096 return qe_invalid;
11097
11098
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11099 return qe_invalid;
11100
11101
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11102 return qe_invalid;
11103
11104 860 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11105 860 }
11106
11107
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11108 {
11109
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11110 return qe_invalid;
11111
11112
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11113 return qe_invalid;
11114
11115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11116 return qe_invalid;
11117
11118 860 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11119 860 }
11120
11121
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11122 {
11123
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11124 return qe_invalid;
11125
11126
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11127 return qe_invalid;
11128
11129
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11130 return qe_invalid;
11131
11132 860 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11133 860 }
11134
11135
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11136 {
11137
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11138 return qe_invalid;
11139
11140
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11141 return qe_invalid;
11142
11143
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11144 return qe_invalid;
11145
11146 860 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11147 860 }
11148
11149
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11150 {
11151
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11152 return qe_invalid;
11153
11154
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11155 return qe_invalid;
11156
11157
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11158 return qe_invalid;
11159
11160 860 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11161 860 }
11162
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11163 {
11164
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11165 return qe_invalid;
11166
11167
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11168 return qe_invalid;
11169
11170
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11171 return qe_invalid;
11172
11173 860 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11174 860 }
11175
11176
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11177 {
11178
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11179 return qe_invalid;
11180
11181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11182 return qe_invalid;
11183
11184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11185 return qe_invalid;
11186
11187 860 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11188 860 }
11189
11190
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11191 {
11192
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11193 return qe_invalid;
11194
11195
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11196 return qe_invalid;
11197
11198
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11199 return qe_invalid;
11200
11201 860 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11202 860 }
11203
11204
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11205 {
11206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_igetl(&tile,f))
11207 return qe_invalid;
11208
11209
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11210 return qe_invalid;
11211
11212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11213 return qe_invalid;
11214
11215 860 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11216 860 }
11217
11218
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11219 {
11220
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11221 return qe_invalid;
11222
11223
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11224 return qe_invalid;
11225
11226
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11227 return qe_invalid;
11228
11229 860 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11230 860 }
11231
11232
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11233 {
11234
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11235 return qe_invalid;
11236
11237
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11238 return qe_invalid;
11239
11240
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11241 return qe_invalid;
11242
11243 860 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11244 860 }
11245
11246
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11247 {
11248
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11249 return qe_invalid;
11250
11251
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&flip,f))
11252 return qe_invalid;
11253
11254
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_getc(&extend,f))
11255 return qe_invalid;
11256
11257 860 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11258 860 }
11259
11260
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 215 times.
860 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11261 {
11262
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(!p_igetl(&tile,f))
11263 return qe_invalid;
11264
11265
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(!p_getc(&flip,f))
11266 return qe_invalid;
11267
11268
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(!p_getc(&extend,f))
11269 return qe_invalid;
11270
11271 645 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11272 645 }
11273 215 }
11274 else
11275 {
11276 memset(frozenspr, 0, sizeof(frozenspr));
11277 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11278 memset(onfirespr, 0, sizeof(onfirespr));
11279 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11280 memset(diggingspr, 0, sizeof(diggingspr));
11281 memset(usingrodspr, 0, sizeof(usingrodspr));
11282 memset(usingcanespr, 0, sizeof(usingcanespr));
11283 memset(pushingspr, 0, sizeof(pushingspr));
11284 memset(liftingspr, 0, sizeof(liftingspr));
11285 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11286 memset(stunnedspr, 0, sizeof(stunnedspr));
11287 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11288 memset(fallingspr, 0, sizeof(fallingspr));
11289 memset(shockedspr, 0, sizeof(shockedspr));
11290 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11291 memset(pullswordspr, 0, sizeof(pullswordspr));
11292 memset(readingspr, 0, sizeof(readingspr));
11293 memset(slash180spr, 0, sizeof(slash180spr));
11294 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11295 memset(dashspr, 0, sizeof(dashspr));
11296 memset(bonkspr, 0, sizeof(bonkspr));
11297 memset(medallionsprs, 0, sizeof(medallionsprs));
11298 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11299 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11300 for(int32_t q = 0; q < 4; ++q)
11301 {
11302 for(int32_t p = 0; p < 3; ++p)
11303 {
11304 drowningspr[q][p] = divespr[q][p];
11305 drowning_lavaspr[q][p] = divespr[q][p];
11306 }
11307 }
11308 }
11309
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 8)
11310 {
11311
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11312 {
11313
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11314 return qe_invalid;
11315
11316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11317 return qe_invalid;
11318
11319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11320 return qe_invalid;
11321
11322 860 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11323 860 }
11324 215 }
11325 else
11326 {
11327 memset(sideswimspr, 0, sizeof(sideswimspr));
11328 }
11329
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 9)
11330 {
11331
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11332 {
11333
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11334 return qe_invalid;
11335
11336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11337 return qe_invalid;
11338
11339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11340 return qe_invalid;
11341
11342 860 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11343 860 }
11344
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11345 {
11346
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11347 return qe_invalid;
11348
11349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11350 return qe_invalid;
11351
11352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11353 return qe_invalid;
11354
11355 860 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11356 860 }
11357
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11358 {
11359
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11360 return qe_invalid;
11361
11362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11363 return qe_invalid;
11364
11365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11366 return qe_invalid;
11367
11368 860 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11369 860 }
11370
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11371 {
11372
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11373 return qe_invalid;
11374
11375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11376 return qe_invalid;
11377
11378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11379 return qe_invalid;
11380
11381 860 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11382 860 }
11383 215 }
11384 else
11385 {
11386 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11387 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11388 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11389 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11390 }
11391
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 10)
11392 {
11393
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11394 {
11395 int32_t hmr;
11396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_igetl(&hmr,f))
11397 return qe_invalid;
11398
11399 860 hammeroffsets[q] = hmr;
11400 860 }
11401 215 }
11402 else
11403 {
11404 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11405 }
11406
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 11)
11407 {
11408
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 215 times.
860 for(int32_t q = 0; q < 3; ++q)
11409 {
11410
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(!p_igetl(&tile,f))
11411 return qe_invalid;
11412
11413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 645 times.
645 if(!p_getc(&flip,f))
11414 return qe_invalid;
11415
11416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 645 times.
645 if(!p_getc(&extend,f))
11417 return qe_invalid;
11418
11419 645 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11420 645 }
11421 215 }
11422 else
11423 {
11424 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11425 }
11426
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 12)
11427 {
11428
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_igetl(&tile,f))
11429 return qe_invalid;
11430
11431
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_getc(&flip,f))
11432 return qe_invalid;
11433
11434
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_getc(&extend,f))
11435 return qe_invalid;
11436 215 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11437
11438 215 }
11439 else
11440 {
11441 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11442 }
11443
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 13)
11444 {
11445
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11446 {
11447
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11448 return qe_invalid;
11449
11450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11451 return qe_invalid;
11452
11453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11454 return qe_invalid;
11455
11456 860 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11457 860 }
11458 215 }
11459 else
11460 {
11461 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11462 }
11463
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 14)
11464 {
11465
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 215 times.
1075 for(int32_t q = 0; q < 4; ++q)
11466 {
11467
1/2
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
860 if(!p_igetl(&tile,f))
11468 return qe_invalid;
11469
11470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&flip,f))
11471 return qe_invalid;
11472
11473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 860 times.
860 if(!p_getc(&extend,f))
11474 return qe_invalid;
11475
11476 860 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11477 860 }
11478 215 }
11479 else
11480 {
11481 memset(revslashspr, 0, sizeof(revslashspr));
11482 }
11483
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if (v_herosprites > 7)
11484 {
11485 215 int32_t num_defense = wMax;
11486 215 byte def = 0;
11487
11488 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11489 /*if(v_herosprites > [x])
11490 * {
11491 * num_defense = 146 //value of wMax on version 8
11492 * }
11493 */
11494
11495
2/2
✓ Branch 0 taken 31390 times.
✓ Branch 1 taken 215 times.
31605 for (int32_t q = 0; q < num_defense; q++)
11496 {
11497
1/2
✓ Branch 0 taken 31390 times.
✗ Branch 1 not taken.
31390 if (!p_getc(&def, f))
11498 return qe_invalid;
11499
11500 31390 hero_defenses[q] = def;
11501 31390 }
11502 215 }
11503 else
11504 {
11505 int32_t num_defense = wMax;
11506 for (int32_t q = 0; q < num_defense; q++)
11507 {
11508 hero_defenses[q] = 0;
11509 }
11510 }
11511 215 }
11512
11513
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 11 times.
215 if(FFCore.quest_format[vInitData] < 34)
11514 {
11515 11 bool fastswim = zinit.hero_swim_speed > 60;
11516 // '2/3' or '1/2'
11517 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11518 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11519 11 }
11520 215 return 0;
11521 215 }
11522
11523
11524 415 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11525 {
11526 //these are here to bypass compiler warnings about unused arguments
11527 415 Header=Header;
11528
11529 dword dummy;
11530 415 word s_version=0;
11531
11532 //section version info
11533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(!p_igetw(&s_version,f))
11534 {
11535 return qe_invalid;
11536 }
11537
11538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (s_version > V_HEROSPRITES)
11539 return qe_version;
11540
11541 415 FFCore.quest_format[vHeroSprites] = s_version;
11542
11543
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!read_deprecated_section_cversion(f))
11544 {
11545 return qe_invalid;
11546 }
11547
11548 //section size
11549
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy,f))
11550 {
11551 return qe_invalid;
11552 }
11553
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if ( s_version >= 6 )
11554 {
11555 215 return readherosprites3(f, s_version);
11556 }
11557 200 else return readherosprites2(f, s_version);
11558 415 }
11559
11560 217 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11561 {
11562 217 subscreens_active.clear();
11563 217 subscreens_passive.clear();
11564 217 subscreens_overlay.clear();
11565 217 subscreens_map.clear();
11566
2/2
✓ Branch 0 taken 27776 times.
✓ Branch 1 taken 217 times.
27993 for(int32_t i=0; i<OLD_MAXCUSTOMSUBSCREENS; i++)
11567 {
11568 subscreen_group g;
11569 27776 memset(&g,0,sizeof(subscreen_group));
11570 27776 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(ret!=0)
11572 return ret;
11573
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 26659 times.
27776 if(g.objects[0].type == ssoNULL) continue;
11574
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 650 times.
1117 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11575 1117 ZCSubscreen& sub = vec.emplace_back();
11576 1117 sub.load_old(g);
11577 1117 }
11578
11579 217 return 0;
11580 217 }
11581
11582 27776 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11583 {
11584 27776 int32_t numsub=0;
11585 27776 byte temp_ss=0;
11586 subscreen_object temp_sub_stack;
11587 27776 subscreen_object *temp_sub = &temp_sub_stack;
11588
11589 char tempname[64];
11590
11591 // FWIW I never saw anything bigger than 20.
11592 #define MAX_DP1_LEN 1024
11593 char tempdp1[MAX_DP1_LEN];
11594
11595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(!pfread(tempname,64,f))
11596 {
11597 return qe_invalid;
11598 }
11599
11600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version > 1)
11601 {
11602
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_getc(&temp_ss,f))
11603 {
11604 return qe_invalid;
11605 }
11606 27776 }
11607
11608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version < 4)
11609 {
11610 uint8_t tmp=0;
11611
11612 if(!p_getc(&tmp,f))
11613 {
11614 return qe_invalid;
11615 }
11616
11617 numsub = (int32_t)tmp;
11618 }
11619 else
11620 {
11621 word tmp;
11622
11623
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_igetw(&tmp, f))
11624 {
11625 return qe_invalid;
11626 }
11627
11628 27776 numsub = (int32_t)tmp;
11629 }
11630
11631 int32_t j;
11632
11633
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71950 times.
✓ Branch 2 taken 44174 times.
✓ Branch 3 taken 27776 times.
71950 for(j=0; (j<OLD_MAXSUBSCREENITEMS&&j<numsub); j++)
11634 {
11635 44174 memset(temp_sub,0,sizeof(subscreen_object));
11636
11637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 switch(g->objects[j].type)
11638 {
11639 case ssoTEXT:
11640 case ssoTEXTBOX:
11641 case ssoCURRENTITEMTEXT:
11642 case ssoCURRENTITEMCLASSTEXT:
11643 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11644
11645 //fall through
11646 default:
11647 44174 memset(&g->objects[j],0,sizeof(subscreen_object));
11648 44174 break;
11649 }
11650
11651
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->type),f))
11652 return qe_invalid;
11653
11654
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->pos),f))
11655 return qe_invalid;
11656
11657
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(s_version < 5)
11658 {
11659 switch(temp_sub->pos)
11660 {
11661 case 0:
11662 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11663 break;
11664
11665 case 1:
11666 temp_sub->pos = sspUP;
11667 break;
11668
11669 case 2:
11670 temp_sub->pos = sspDOWN;
11671 break;
11672
11673 default:
11674 temp_sub->pos = 0;
11675 }
11676 }
11677
11678
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->x),f))
11679 return qe_invalid;
11680
11681
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->y),f))
11682 return qe_invalid;
11683
11684
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->w),f))
11685 return qe_invalid;
11686
11687
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->h),f))
11688 return qe_invalid;
11689
11690
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype1),f))
11691 return qe_invalid;
11692
11693
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color1),f))
11694 return qe_invalid;
11695
11696
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype2),f))
11697 return qe_invalid;
11698
11699
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color2),f))
11700 return qe_invalid;
11701
11702
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype3),f))
11703 return qe_invalid;
11704
11705
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color3),f))
11706 return qe_invalid;
11707
11708
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d1),f))
11709 return qe_invalid;
11710
11711
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d2),f))
11712 return qe_invalid;
11713
11714
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d3),f))
11715 return qe_invalid;
11716
11717
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d4),f))
11718 return qe_invalid;
11719
11720
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d5),f))
11721 return qe_invalid;
11722
11723
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d6),f))
11724 return qe_invalid;
11725
11726
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d7),f))
11727 return qe_invalid;
11728
11729
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d8),f))
11730 return qe_invalid;
11731
11732
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d9),f))
11733 return qe_invalid;
11734
11735
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d10),f))
11736 return qe_invalid;
11737
11738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 if(s_version < 2)
11739 {
11740 if(!p_igetl(&(temp_sub->speed),f))
11741 return qe_invalid;
11742
11743 if(!p_igetl(&(temp_sub->delay),f))
11744 return qe_invalid;
11745
11746 if(!p_igetl(&(temp_sub->frame),f))
11747 return qe_invalid;
11748 }
11749 else
11750 {
11751
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->speed),f))
11752 return qe_invalid;
11753
11754
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->delay),f))
11755 return qe_invalid;
11756
11757
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->frame),f))
11758 return qe_invalid;
11759 }
11760
11761 44174 int32_t temp_size=0;
11762
11763 // bool deletets = false;
11764
4/4
✓ Branch 0 taken 19541 times.
✓ Branch 1 taken 3389 times.
✓ Branch 2 taken 21002 times.
✓ Branch 3 taken 242 times.
44174 switch(temp_sub->type)
11765 {
11766 case ssoTEXT:
11767 case ssoTEXTBOX:
11768 case ssoCURRENTITEMTEXT:
11769 case ssoCURRENTITEMCLASSTEXT:
11770 {
11771 word temptempsize;
11772
11773
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!p_igetw(&temptempsize,f))
11774 {
11775 return qe_invalid;
11776 }
11777
11778 //temptempsize = temp1 + (temp2 << 8);
11779 3389 temp_size = (int32_t)temptempsize;
11780 3389 uint32_t char_length = temp_size+2;
11781
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if (char_length > MAX_DP1_LEN)
11782 {
11783 return qe_invalid;
11784 }
11785 3389 tempdp1[char_length - 1] = '\0';
11786
11787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
3389 if(temp_size)
11788
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!pfread(tempdp1,temp_size+1,f))
11789 return qe_invalid;
11790 3389 break;
11791 }
11792
11793 case ssoLIFEMETER:
11794
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11795 temp_sub->d3 = 1;
11796
11797
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(!p_getc(&(temp_sub->dp1),f))
11798 return qe_invalid;
11799
11800 242 break;
11801
11802
11803 case ssoCURRENTITEM:
11804
11805
1/2
✓ Branch 0 taken 19541 times.
✗ Branch 1 not taken.
19541 if(s_version < 6)
11806 {
11807 switch(temp_sub->d1)
11808 {
11809 case ssiBOMB:
11810 temp_sub->d1 = itype_bomb;
11811 break;
11812
11813 case ssiSWORD:
11814 temp_sub->d1 = itype_sword;
11815 break;
11816
11817 case ssiSHIELD:
11818 temp_sub->d1 = itype_shield;
11819 break;
11820
11821 case ssiCANDLE:
11822 temp_sub->d1 = itype_candle;
11823 break;
11824
11825 case ssiLETTER:
11826 temp_sub->d1 = itype_letter;
11827 break;
11828
11829 case ssiPOTION:
11830 temp_sub->d1 = itype_potion;
11831 break;
11832
11833 case ssiLETTERPOTION:
11834 temp_sub->d1 = itype_letterpotion;
11835 break;
11836
11837 case ssiBOW:
11838 temp_sub->d1 = itype_bow;
11839 break;
11840
11841 case ssiARROW:
11842 temp_sub->d1 = itype_arrow;
11843 break;
11844
11845 case ssiBOWANDARROW:
11846 temp_sub->d1 = itype_bowandarrow;
11847 break;
11848
11849 case ssiBAIT:
11850 temp_sub->d1 = itype_bait;
11851 break;
11852
11853 case ssiRING:
11854 temp_sub->d1 = itype_ring;
11855 break;
11856
11857 case ssiBRACELET:
11858 temp_sub->d1 = itype_bracelet;
11859 break;
11860
11861 case ssiMAP:
11862 temp_sub->d1 = itype_map;
11863 break;
11864
11865 case ssiCOMPASS:
11866 temp_sub->d1 = itype_compass;
11867 break;
11868
11869 case ssiBOSSKEY:
11870 temp_sub->d1 = itype_bosskey;
11871 break;
11872
11873 case ssiMAGICKEY:
11874 temp_sub->d1 = itype_magickey;
11875 break;
11876
11877 case ssiBRANG:
11878 temp_sub->d1 = itype_brang;
11879 break;
11880
11881 case ssiWAND:
11882 temp_sub->d1 = itype_wand;
11883 break;
11884
11885 case ssiRAFT:
11886 temp_sub->d1 = itype_raft;
11887 break;
11888
11889 case ssiLADDER:
11890 temp_sub->d1 = itype_ladder;
11891 break;
11892
11893 case ssiWHISTLE:
11894 temp_sub->d1 = itype_whistle;
11895 break;
11896
11897 case ssiBOOK:
11898 temp_sub->d1 = itype_book;
11899 break;
11900
11901 case ssiWALLET:
11902 temp_sub->d1 = itype_wallet;
11903 break;
11904
11905 case ssiSBOMB:
11906 temp_sub->d1 = itype_sbomb;
11907 break;
11908
11909 case ssiHCPIECE:
11910 temp_sub->d1 = itype_heartpiece;
11911 break;
11912
11913 case ssiAMULET:
11914 temp_sub->d1 = itype_amulet;
11915 break;
11916
11917 case ssiFLIPPERS:
11918 temp_sub->d1 = itype_flippers;
11919 break;
11920
11921 case ssiHOOKSHOT:
11922 temp_sub->d1 = itype_hookshot;
11923 break;
11924
11925 case ssiLENS:
11926 temp_sub->d1 = itype_lens;
11927 break;
11928
11929 case ssiHAMMER:
11930 temp_sub->d1 = itype_hammer;
11931 break;
11932
11933 case ssiBOOTS:
11934 temp_sub->d1 = itype_boots;
11935 break;
11936
11937 case ssiDIVINEFIRE:
11938 temp_sub->d1 = itype_divinefire;
11939 break;
11940
11941 case ssiDIVINEESCAPE:
11942 temp_sub->d1 = itype_divineescape;
11943 break;
11944
11945 case ssiDIVINEPROTECTION:
11946 temp_sub->d1 = itype_divineprotection;
11947 break;
11948
11949 case ssiQUIVER:
11950 temp_sub->d1 = itype_quiver;
11951 break;
11952
11953 case ssiBOMBBAG:
11954 temp_sub->d1 = itype_bombbag;
11955 break;
11956
11957 case ssiCBYRNA:
11958 temp_sub->d1 = itype_cbyrna;
11959 break;
11960
11961 case ssiROCS:
11962 temp_sub->d1 = itype_rocs;
11963 break;
11964
11965 case ssiHOVERBOOTS:
11966 temp_sub->d1 = itype_hoverboots;
11967 break;
11968
11969 case ssiSPINSCROLL:
11970 temp_sub->d1 = itype_spinscroll;
11971 break;
11972
11973 case ssiCROSSSCROLL:
11974 temp_sub->d1 = itype_crossscroll;
11975 break;
11976
11977 case ssiQUAKESCROLL:
11978 temp_sub->d1 = itype_quakescroll;
11979 break;
11980
11981 case ssiWHISPRING:
11982 temp_sub->d1 = itype_whispring;
11983 break;
11984
11985 case ssiCHARGERING:
11986 temp_sub->d1 = itype_chargering;
11987 break;
11988
11989 case ssiPERILSCROLL:
11990 temp_sub->d1 = itype_perilscroll;
11991 break;
11992
11993 case ssiWEALTHMEDAL:
11994 temp_sub->d1 = itype_wealthmedal;
11995 break;
11996
11997 case ssiHEARTRING:
11998 temp_sub->d1 = itype_heartring;
11999 break;
12000
12001 case ssiMAGICRING:
12002 temp_sub->d1 = itype_magicring;
12003 break;
12004
12005 case ssiSPINSCROLL2:
12006 temp_sub->d1 = itype_spinscroll2;
12007 break;
12008
12009 case ssiQUAKESCROLL2:
12010 temp_sub->d1 = itype_quakescroll2;
12011 break;
12012
12013 case ssiAGONY:
12014 temp_sub->d1 = itype_agony;
12015 break;
12016
12017 case ssiSTOMPBOOTS:
12018 temp_sub->d1 = itype_stompboots;
12019 break;
12020
12021 case ssiWHIMSICALRING:
12022 temp_sub->d1 = itype_whimsicalring;
12023 break;
12024
12025 case ssiPERILRING:
12026 temp_sub->d1 = itype_perilring;
12027 break;
12028
12029 default:
12030 temp_sub->d1 += itype_custom1 - ssiMAX;
12031 }
12032 }
12033
12034 //fall-through
12035 default:
12036
1/2
✓ Branch 0 taken 40543 times.
✗ Branch 1 not taken.
40543 if(!p_getc(&(temp_sub->dp1),f))
12037 return qe_invalid;
12038
12039 40543 break;
12040 }
12041
12042
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 35480 times.
44174 if(s_version < 7)
12043 {
12044
3/3
✓ Branch 0 taken 29642 times.
✓ Branch 1 taken 1270 times.
✓ Branch 2 taken 4568 times.
35480 switch(temp_sub->type)
12045 {
12046 case ssoMAGICGAUGE:
12047 {
12048
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 1136 times.
1270 if(!temp_sub->d9)
12049 1136 temp_sub->d9 = -1; //-1 now represents 'always'
12050 1270 break;
12051 }
12052 case ssoLIFEGAUGE:
12053 4568 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
12054 4568 break;
12055 }
12056 35480 }
12057
12058
3/3
✓ Branch 0 taken 3389 times.
✓ Branch 1 taken 39307 times.
✓ Branch 2 taken 1478 times.
44174 switch(temp_sub->type)
12059 {
12060 case ssoTEXT:
12061 case ssoTEXTBOX:
12062 case ssoCURRENTITEMTEXT:
12063 case ssoCURRENTITEMCLASSTEXT:
12064
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3389 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
12065
12066 3389 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
12067 3389 g->objects[j].dp1 = new char[temp_size+2];
12068 3389 strcpy((char*)g->objects[j].dp1,tempdp1);
12069 3389 break;
12070
12071 case ssoCOUNTER:
12072
1/2
✓ Branch 0 taken 1478 times.
✗ Branch 1 not taken.
1478 if(s_version<3)
12073 {
12074 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
12075 temp_sub->d8=0;
12076 }
12077
12078 default:
12079 40785 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
12080 40785 break;
12081 }
12082
12083 44174 g->name[0] = '\0';
12084 44174 strncat(g->name, tempname, 64 - 1);
12085 44174 g->ss_type = temp_ss;
12086 44174 }
12087
12088
2/2
✓ Branch 0 taken 7066482 times.
✓ Branch 1 taken 27776 times.
7094258 for(j=numsub; j<OLD_MAXSUBSCREENITEMS; j++)
12089 {
12090 //clear all unused object in this subscreen -DD
12091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7066482 times.
7066482 switch(g->objects[j].type)
12092 {
12093 case ssoTEXT:
12094 case ssoTEXTBOX:
12095 case ssoCURRENTITEMTEXT:
12096 case ssoCURRENTITEMCLASSTEXT:
12097 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
12098
12099 //fall through
12100 default:
12101 7066482 memset(&g->objects[j],0,sizeof(subscreen_object));
12102 7066482 break;
12103 }
12104 7066482 }
12105
12106 27776 return 0;
12107 27776 }
12108
12109 415 int32_t readsubscreens(PACKFILE *f)
12110 {
12111 word s_version;
12112 dword dummy;
12113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(!p_igetw(&s_version,f))
12114 return qe_invalid;
12115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (s_version > V_SUBSCREEN)
12116 return qe_version;
12117 415 FFCore.quest_format[vSubscreen] = s_version;
12118
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!read_deprecated_section_cversion(f))
12119 return qe_invalid;
12120
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy,f)) //section size
12121 return qe_invalid;
12122
12123
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 198 times.
415 if(s_version < 8)
12124 217 return read_old_subscreens(f,s_version);
12125
12126 198 subscreens_active.clear();
12127 198 subscreens_passive.clear();
12128 198 subscreens_overlay.clear();
12129 198 subscreens_map.clear();
12130
12131 byte sz;
12132
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&sz,f))
12133 return qe_invalid;
12134
2/2
✓ Branch 0 taken 626 times.
✓ Branch 1 taken 198 times.
824 for(byte q = 0; q < sz; ++q)
12135 {
12136 626 ZCSubscreen& tmp = subscreens_active.emplace_back();
12137
1/2
✓ Branch 0 taken 626 times.
✗ Branch 1 not taken.
626 if (auto ret = tmp.read(f, s_version))
12138 return ret;
12139 626 }
12140
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&sz,f))
12141 return qe_invalid;
12142
2/2
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 198 times.
951 for(byte q = 0; q < sz; ++q)
12143 {
12144 753 ZCSubscreen& tmp = subscreens_passive.emplace_back();
12145
1/2
✓ Branch 0 taken 753 times.
✗ Branch 1 not taken.
753 if (auto ret = tmp.read(f, s_version))
12146 return ret;
12147 753 }
12148
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&sz,f))
12149 return qe_invalid;
12150
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 198 times.
208 for(byte q = 0; q < sz; ++q)
12151 {
12152 10 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
12153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (auto ret = tmp.read(f, s_version))
12154 return ret;
12155 10 }
12156
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 133 times.
198 if (s_version >= 16)
12157 {
12158
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&sz,f))
12159 return qe_invalid;
12160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 for(byte q = 0; q < sz; ++q)
12161 {
12162 ZCSubscreen& tmp = subscreens_map.emplace_back();
12163 if (auto ret = tmp.read(f, s_version))
12164 return ret;
12165 }
12166 133 }
12167 198 return 0;
12168 415 }
12169
12170 void reset_subscreen(subscreen_group *tempss)
12171 {
12172 for(int32_t i=0; i<OLD_MAXSUBSCREENITEMS; ++i)
12173 {
12174 switch(tempss->objects[i].type)
12175 {
12176 case ssoTEXT:
12177 case ssoTEXTBOX:
12178 case ssoCURRENTITEMTEXT:
12179 case ssoCURRENTITEMCLASSTEXT:
12180 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12181
12182 //fall through
12183 default:
12184 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12185 break;
12186 }
12187 }
12188 }
12189
12190 117 void reset_subscreens()
12191 {
12192 117 subscreens_active.clear();
12193 117 subscreens_passive.clear();
12194 117 subscreens_overlay.clear();
12195 117 subscreens_map.clear();
12196 117 }
12197
12198 117 int32_t setupsubscreens()
12199 {
12200 117 reset_subscreens();
12201 //return 0;
12202
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 234 times.
351 for(int q = 0; q < 2; ++q)
12203 {
12204 234 subscreens_active.emplace_back();
12205 234 subscreens_passive.emplace_back();
12206 234 }
12207 117 int32_t tempsubscreen=subscr_mode;
12208
12209
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if(tempsubscreen>=ssdtMAX)
12210 tempsubscreen=0;
12211
12212
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
117 switch(tempsubscreen)
12213 {
12214 case ssdtOLD:
12215 case ssdtNEWSUBSCR:
12216 case ssdtREV2:
12217 case ssdtBSZELDA:
12218 case ssdtBSZELDAMODIFIED:
12219 case ssdtBSZELDAENHANCED:
12220 case ssdtBSZELDACOMPLETE:
12221 {
12222 117 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
12223 117 subscreens_active[0].sub_type=sstACTIVE;
12224 117 subscreens_active[0].name = "Active Subscreen (Triforce)";
12225 117 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
12226 117 subscreens_active[1].sub_type=sstACTIVE;
12227 117 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
12228 117 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
12229 117 subscreens_passive[0].sub_type=sstPASSIVE;
12230 117 subscreens_passive[0].name = "Passive Subscreen (Magic)";
12231 117 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
12232 117 subscreens_passive[1].sub_type=sstPASSIVE;
12233 117 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
12234 117 break;
12235 }
12236
12237 case ssdtZ3:
12238 {
12239 subscreens_active[0].load_old(z3_active_a);
12240 subscreens_active[0].sub_type=sstACTIVE;
12241 subscreens_active[1].load_old(z3_active_ab);
12242 subscreens_active[1].sub_type=sstACTIVE;
12243 subscreens_passive[0].load_old(z3_passive_a);
12244 subscreens_passive[0].sub_type=sstPASSIVE;
12245 subscreens_passive[1].load_old(z3_passive_ab);
12246 subscreens_passive[1].sub_type=sstPASSIVE;
12247 break;
12248 }
12249 }
12250 117 subscr_mode = ssdtMAX;
12251 117 return 0;
12252 }
12253
12254 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
12255
12256 extern script_data *ffscripts[NUMSCRIPTFFC];
12257 extern script_data *itemscripts[NUMSCRIPTITEM];
12258 extern script_data *guyscripts[NUMSCRIPTGUYS];
12259 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12260 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12261 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12262 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12263 extern script_data *playerscripts[NUMSCRIPTHERO];
12264 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12265 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12266 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12267 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12268 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
12269
12270 static std::vector<const script_data*> read_scripts;
12271
12272 442 static script_data fake_script_data(ScriptType::None, 0);
12273
12274 527 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12275 {
12276 int32_t dummy;
12277 527 word s_version=0, zmeta_version=0;
12278 527 byte numscripts=0;
12279 527 numscripts=numscripts; //to avoid unused variables warnings
12280 int32_t ret;
12281 527 read_scripts.clear();
12282 527 zasm_scripts.clear();
12283
12284 //section version info
12285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if(!p_igetw(&s_version,f))
12286 {
12287 return qe_invalid;
12288 }
12289
12290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if (s_version > V_FFSCRIPT)
12291 return qe_version;
12292
12293 527 FFCore.quest_format[vFFScript] = s_version;
12294
12295
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!read_deprecated_section_cversion(f))
12296 {
12297 return qe_invalid;
12298 }
12299
12300
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 215 times.
527 if(s_version >= 18)
12301 {
12302
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_igetw(&zmeta_version,f))
12303 {
12304 return qe_invalid;
12305 }
12306 215 }
12307
12308 //section size
12309
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!p_igetl(&dummy,f))
12310 {
12311 return qe_invalid;
12312 }
12313
12314
2/2
✓ Branch 0 taken 307 times.
✓ Branch 1 taken 220 times.
527 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12315 527 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12316
12317
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 148 times.
527 if(s_version >= 27)
12318 {
12319 148 ret = read_quest_zasm(f, s_version);
12320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(ret)
12321 return qe_invalid;
12322 148 }
12323
12324 //finally... section data
12325
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 451 times.
212931 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12326 {
12327 212480 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12328
12329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
212480 if (ret)
12330 {
12331 return qe_invalid;
12332 }
12333 212480 }
12334
12335 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12336 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12337 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12338 * there was a version bump a week before a change that broke stuff.
12339 */
12340
7/8
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
✓ Branch 4 taken 215 times.
✓ Branch 5 taken 215 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 215 times.
451 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12341 {
12342 666 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12343 666 }
12344
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if(s_version < 19)
12345 {
12346 200 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12347 200 }
12348
12349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(s_version > 1)
12350 {
12351
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12352 {
12353 106240 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12354
12355
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if (ret)
12356 {
12357 return qe_invalid;
12358 }
12359 106240 }
12360
12361
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12362 {
12363 106240 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12364
12365
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if (ret)
12366 {
12367 return qe_invalid;
12368 }
12369 106240 }
12370
12371
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12372 {
12373 106240 ret = read_one_ffscript(f, Header, i, s_version, &fake_script_data, zmeta_version);
12374
12375
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if (ret)
12376 {
12377 return qe_invalid;
12378 }
12379 106240 }
12380
12381
2/2
✓ Branch 0 taken 106240 times.
✓ Branch 1 taken 415 times.
106655 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12382 {
12383 106240 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12384
12385
1/2
✓ Branch 0 taken 106240 times.
✗ Branch 1 not taken.
106240 if (ret)
12386 {
12387 return qe_invalid;
12388 }
12389 106240 }
12390
12391
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if(s_version > 16)
12392 {
12393
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 215 times.
1935 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12394 {
12395 1720 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12396
12397
1/2
✓ Branch 0 taken 1720 times.
✗ Branch 1 not taken.
1720 if (ret)
12398 {
12399 return qe_invalid;
12400 }
12401 1720 }
12402 215 }
12403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 else if(s_version > 13)
12404 {
12405 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12406 {
12407 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12408
12409 if (ret)
12410 {
12411 return qe_invalid;
12412 }
12413 }
12414
12415 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12416 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12417
12418 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12419 }
12420
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 else if(s_version > 4)
12421 {
12422
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12423 {
12424 800 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12425
12426
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if (ret)
12427 {
12428 return qe_invalid;
12429 }
12430 800 }
12431
12432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12433
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12434
12435
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12436
12437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12438
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12439
12440
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12441
12442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12443
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_F6];
12444
12445
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12446
12447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12448
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12449
12450
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12451 200 }
12452 else
12453 {
12454 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12455 {
12456 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12457
12458 if (ret)
12459 {
12460 return qe_invalid;
12461 }
12462 }
12463
12464 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12465 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12466
12467 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12468
12469 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12470 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12471
12472 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12473
12474 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12475 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12476
12477 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12478
12479 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12480 delete globalscripts[GLOBAL_SCRIPT_F6];
12481
12482 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12483
12484 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12485 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12486
12487 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12488 }
12489
12490
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if(s_version > 10) //expanded the number of Hero scripts to 5.
12491 {
12492
2/2
✓ Branch 0 taken 1075 times.
✓ Branch 1 taken 215 times.
1290 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12493 {
12494 1075 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12495
12496
1/2
✓ Branch 0 taken 1075 times.
✗ Branch 1 not taken.
1075 if (ret)
12497 {
12498 return qe_invalid;
12499 }
12500 1075 }
12501 215 }
12502 else
12503 {
12504
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 200 times.
800 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12505 {
12506 600 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12507
12508
1/2
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
600 if (ret)
12509 {
12510 return qe_invalid;
12511 }
12512 600 }
12513
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[3] != NULL)
12514
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete playerscripts[3];
12515
12516
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12517
12518
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[4] != NULL)
12519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 delete playerscripts[4];
12520
12521
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12522 }
12523
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
415 if(s_version > 8 && s_version < 10)
12524 {
12525
12526 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12527 {
12528 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12529
12530 if (ret)
12531 {
12532 return qe_invalid;
12533 }
12534 }
12535 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12536 {
12537 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12538
12539 if (ret)
12540 {
12541 return qe_invalid;
12542 }
12543 }
12544
12545 }
12546
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version >= 10)
12547 {
12548
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12549 {
12550 55040 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12551
12552
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if (ret)
12553 {
12554 return qe_invalid;
12555 }
12556 55040 }
12557
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12558 {
12559 55040 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12560
12561
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if (ret)
12562 {
12563 return qe_invalid;
12564 }
12565 55040 }
12566
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12567 {
12568 55040 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12569
12570
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if (ret)
12571 {
12572 return qe_invalid;
12573 }
12574 55040 }
12575
12576 215 }
12577
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version >=12)
12578 {
12579
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 215 times.
55255 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12580 {
12581 55040 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12582
12583
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if (ret)
12584 {
12585 return qe_invalid;
12586 }
12587 55040 }
12588 215 }
12589
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version >=15)
12590 {
12591
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 215 times.
110295 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12592 {
12593 110080 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12594
12595
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if (ret)
12596 {
12597 return qe_invalid;
12598 }
12599 110080 }
12600 215 }
12601
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version >19)
12602 {
12603 215 word numgenscripts = NUMSCRIPTSGENERIC;
12604
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_igetw(&numgenscripts,f))
12605 {
12606 return qe_invalid;
12607 }
12608
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 215 times.
110295 for(int32_t i = 0; i < numgenscripts; i++)
12609 {
12610 110080 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12611
12612
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if (ret)
12613 {
12614 return qe_invalid;
12615 }
12616 110080 }
12617 215 }
12618
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 198 times.
415 if(s_version >21)
12619 {
12620 198 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12621
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetw(&numsubscripts,f))
12622 {
12623 return qe_invalid;
12624 }
12625
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t i = 0; i < numsubscripts; i++)
12626 {
12627 50688 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12628
12629
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (ret)
12630 {
12631 return qe_invalid;
12632 }
12633 50688 }
12634 198 }
12635 415 }
12636
12637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(s_version > 2)
12638 {
12639 int32_t bufsize;
12640 415 p_igetl(&bufsize, f);
12641
2/4
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
415 if (bufsize < 0 || bufsize > 1024*1024*10)
12642 {
12643 // God help anyone storing more than 10MB of code in the script buffer.
12644 return qe_invalid;
12645 }
12646 415 char * buf = new char[bufsize+1];
12647 415 pfread(buf, bufsize, f);
12648 415 buf[bufsize]=0;
12649
12650
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 zScript = string(buf);
12651
12652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 delete[] buf;
12653 word numffcbindings;
12654 415 p_igetw(&numffcbindings, f);
12655
12656
2/2
✓ Branch 0 taken 11855 times.
✓ Branch 1 taken 415 times.
12270 for(int32_t i=0; i<numffcbindings; i++)
12657 {
12658 word id;
12659 11855 p_igetw(&id, f);
12660 11855 p_igetl(&bufsize, f);
12661
2/4
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11855 times.
11855 if (bufsize < 0 || bufsize > 1024)
12662 return qe_invalid;
12663 11855 buf = new char[bufsize+1];
12664 11855 pfread(buf, bufsize, f);
12665 11855 buf[bufsize]=0;
12666
12667 //fix for buggy older saved quests -DD
12668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11855 times.
11855 if(id < NUMSCRIPTFFC-1)
12669 11855 ffcmap[id].scriptname = buf;
12670
12671
1/2
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
11855 delete[] buf;
12672 11855 }
12673
12674 word numglobalbindings;
12675 415 p_igetw(&numglobalbindings, f);
12676
12677
2/2
✓ Branch 0 taken 1672 times.
✓ Branch 1 taken 415 times.
2087 for(int32_t i=0; i<numglobalbindings; i++)
12678 {
12679 word id;
12680 1672 p_igetw(&id, f);
12681 1672 p_igetl(&bufsize, f);
12682
2/4
✓ Branch 0 taken 1672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1672 times.
✗ Branch 3 not taken.
1672 if (bufsize < 0 || bufsize > 1024)
12683 return qe_invalid;
12684 1672 buf = new char[bufsize+1];
12685 1672 pfread(buf, bufsize, f);
12686 1672 buf[bufsize]=0;
12687
12688 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12689 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12690 // Ignore these. -DD
12691
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 1126 times.
1672 if (id < NUMSCRIPTGLOBAL)
12692 {
12693 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12694
1/2
✓ Branch 0 taken 1126 times.
✗ Branch 1 not taken.
1126 if(strcmp(buf,"~Continue") == 0)
12695 {
12696 globalmap[id].scriptname = "";
12697
12698 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12699 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12700 }
12701 else
12702 {
12703 1126 globalmap[id].scriptname = buf;
12704 }
12705 1126 }
12706
12707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1672 times.
1672 delete[] buf;
12708 1672 }
12709
12710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(s_version > 3)
12711 {
12712 word numitembindings;
12713 415 p_igetw(&numitembindings, f);
12714
12715
2/2
✓ Branch 0 taken 1391 times.
✓ Branch 1 taken 415 times.
1806 for(int32_t i=0; i<numitembindings; i++)
12716 {
12717 word id;
12718 1391 p_igetw(&id, f);
12719 1391 p_igetl(&bufsize, f);
12720
2/4
✓ Branch 0 taken 1391 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1391 times.
1391 if (bufsize < 0 || bufsize > 1024)
12721 return qe_invalid;
12722 1391 buf = new char[bufsize+1];
12723 1391 pfread(buf, bufsize, f);
12724 1391 buf[bufsize]=0;
12725
12726 //fix this too
12727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1391 times.
1391 if(id <NUMSCRIPTITEM-1)
12728 1391 itemmap[id].scriptname = buf;
12729
12730
1/2
✓ Branch 0 taken 1391 times.
✗ Branch 1 not taken.
1391 delete[] buf;
12731 1391 }
12732 415 }
12733 //(v9+)
12734
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version > 8)
12735 {
12736 //npc scripts
12737 word numnpcbindings;
12738 215 p_igetw(&numnpcbindings, f);
12739
12740
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 215 times.
407 for(int32_t i=0; i<numnpcbindings; i++)
12741 {
12742 word id;
12743 192 p_igetw(&id, f);
12744 192 p_igetl(&bufsize, f);
12745
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if (bufsize < 0 || bufsize > 1024)
12746 return qe_invalid;
12747 192 buf = new char[bufsize+1];
12748 192 pfread(buf, bufsize, f);
12749 192 buf[bufsize]=0;
12750
12751 //fix this too
12752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(id <NUMSCRIPTGUYS-1)
12753 192 npcmap[id].scriptname = buf;
12754
12755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 delete[] buf;
12756 192 }
12757 //lweapon
12758 word numlwpnbindings;
12759 215 p_igetw(&numlwpnbindings, f);
12760
12761
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 215 times.
648 for(int32_t i=0; i<numlwpnbindings; i++)
12762 {
12763 word id;
12764 433 p_igetw(&id, f);
12765 433 p_igetl(&bufsize, f);
12766
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
433 if (bufsize < 0 || bufsize > 1024)
12767 return qe_invalid;
12768 433 buf = new char[bufsize+1];
12769 433 pfread(buf, bufsize, f);
12770 433 buf[bufsize]=0;
12771
12772 //fix this too
12773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(id <NUMSCRIPTWEAPONS-1)
12774 433 lwpnmap[id].scriptname = buf;
12775
12776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 delete[] buf;
12777 433 }
12778 //eweapon
12779 word numewpnbindings;
12780 215 p_igetw(&numewpnbindings, f);
12781
12782
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 215 times.
652 for(int32_t i=0; i<numewpnbindings; i++)
12783 {
12784 word id;
12785 437 p_igetw(&id, f);
12786 437 p_igetl(&bufsize, f);
12787
2/4
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437 times.
✗ Branch 3 not taken.
437 if (bufsize < 0 || bufsize > 1024)
12788 return qe_invalid;
12789 437 buf = new char[bufsize+1];
12790 437 pfread(buf, bufsize, f);
12791 437 buf[bufsize]=0;
12792
12793 //fix this too
12794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 if(id <NUMSCRIPTWEAPONS-1)
12795 437 ewpnmap[id].scriptname = buf;
12796
12797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 delete[] buf;
12798 437 }
12799 //hero
12800 word numherobindings;
12801 215 p_igetw(&numherobindings, f);
12802
12803
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 215 times.
258 for(int32_t i=0; i<numherobindings; i++)
12804 {
12805 word id;
12806 43 p_igetw(&id, f);
12807 43 p_igetl(&bufsize, f);
12808
2/4
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
43 if (bufsize < 0 || bufsize > 1024)
12809 return qe_invalid;
12810 43 buf = new char[bufsize+1];
12811 43 pfread(buf, bufsize, f);
12812 43 buf[bufsize]=0;
12813
12814 //fix this too
12815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(id <NUMSCRIPTHERO-1)
12816 43 playermap[id].scriptname = buf;
12817
12818
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 delete[] buf;
12819 43 }
12820 //dmaps
12821 word numdmapbindings;
12822 215 p_igetw(&numdmapbindings, f);
12823
12824
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 215 times.
776 for(int32_t i=0; i<numdmapbindings; i++)
12825 {
12826 word id;
12827 561 p_igetw(&id, f);
12828 561 p_igetl(&bufsize, f);
12829
2/4
✓ Branch 0 taken 561 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 561 times.
561 if (bufsize < 0 || bufsize > 1024)
12830 return qe_invalid;
12831 561 buf = new char[bufsize+1];
12832 561 pfread(buf, bufsize, f);
12833 561 buf[bufsize]=0;
12834
12835 //fix this too
12836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 561 times.
561 if(id <NUMSCRIPTSDMAP-1)
12837 561 dmapmap[id].scriptname = buf;
12838
12839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 561 times.
561 delete[] buf;
12840 561 }
12841 //screen
12842 word numscreenbindings;
12843 215 p_igetw(&numscreenbindings, f);
12844
12845
2/2
✓ Branch 0 taken 445 times.
✓ Branch 1 taken 215 times.
660 for(int32_t i=0; i<numscreenbindings; i++)
12846 {
12847 word id;
12848 445 p_igetw(&id, f);
12849 445 p_igetl(&bufsize, f);
12850
2/4
✓ Branch 0 taken 445 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 445 times.
✗ Branch 3 not taken.
445 if (bufsize < 0 || bufsize > 1024)
12851 return qe_invalid;
12852 445 buf = new char[bufsize+1];
12853 445 pfread(buf, bufsize, f);
12854 445 buf[bufsize]=0;
12855
12856 //fix this too
12857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445 times.
445 if(id <NUMSCRIPTSDMAP-1)
12858 445 screenmap[id].scriptname = buf;
12859
12860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445 times.
445 delete[] buf;
12861 445 }
12862 215 }
12863
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version > 11)
12864 {
12865 word numspritebindings;
12866 215 p_igetw(&numspritebindings, f);
12867
12868
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 215 times.
286 for(int32_t i=0; i<numspritebindings; i++)
12869 {
12870 word id;
12871 71 p_igetw(&id, f);
12872 71 p_igetl(&bufsize, f);
12873
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 71 times.
71 if (bufsize < 0 || bufsize > 1024)
12874 return qe_invalid;
12875 71 buf = new char[bufsize+1];
12876 71 pfread(buf, bufsize, f);
12877 71 buf[bufsize]=0;
12878
12879 //fix this too
12880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(id <NUMSCRIPTSDMAP-1)
12881 71 itemspritemap[id].scriptname = buf;
12882
12883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 delete[] buf;
12884 71 }
12885 215 }
12886
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version >= 15)
12887 {
12888 word numcombobindings;
12889 215 p_igetw(&numcombobindings, f);
12890
12891
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 215 times.
432 for(int32_t i=0; i<numcombobindings; i++)
12892 {
12893 word id;
12894 217 p_igetw(&id, f);
12895 217 p_igetl(&bufsize, f);
12896
2/4
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
217 if (bufsize < 0 || bufsize > 1024)
12897 return qe_invalid;
12898 217 buf = new char[bufsize+1];
12899 217 pfread(buf, bufsize, f);
12900 217 buf[bufsize]=0;
12901
12902 //fix this too
12903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(id <NUMSCRIPTSCOMBODATA-1)
12904 217 comboscriptmap[id].scriptname = buf;
12905
12906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 delete[] buf;
12907 217 }
12908 215 }
12909
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if(s_version > 19)
12910 {
12911 word numgenericbindings;
12912 215 p_igetw(&numgenericbindings, f);
12913
12914
2/2
✓ Branch 0 taken 2624 times.
✓ Branch 1 taken 215 times.
2839 for(int32_t i=0; i<numgenericbindings; i++)
12915 {
12916 word id;
12917 2624 p_igetw(&id, f);
12918 2624 p_igetl(&bufsize, f);
12919
2/4
✓ Branch 0 taken 2624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2624 times.
✗ Branch 3 not taken.
2624 if (bufsize < 0 || bufsize > 1024)
12920 return qe_invalid;
12921 2624 buf = new char[bufsize+1];
12922 2624 pfread(buf, bufsize, f);
12923 2624 buf[bufsize]=0;
12924
12925 //fix this too
12926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2624 times.
2624 if(id <NUMSCRIPTSGENERIC-1)
12927 2624 genericmap[id].scriptname = buf;
12928
12929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2624 times.
2624 delete[] buf;
12930 2624 }
12931 215 }
12932
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 198 times.
415 if(s_version > 21)
12933 {
12934 word numsubscreenbindings;
12935 198 p_igetw(&numsubscreenbindings, f);
12936
12937
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 198 times.
216 for(int32_t i=0; i<numsubscreenbindings; i++)
12938 {
12939 word id;
12940 18 p_igetw(&id, f);
12941 18 p_igetl(&bufsize, f);
12942
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if (bufsize < 0 || bufsize > 1024)
12943 return qe_invalid;
12944 18 buf = new char[bufsize+1];
12945 18 pfread(buf, bufsize, f);
12946 18 buf[bufsize]=0;
12947
12948 //fix this too
12949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(id <NUMSCRIPTSSUBSCREEN-1)
12950 18 subscreenmap[id].scriptname = buf;
12951
12952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 delete[] buf;
12953 18 }
12954 198 }
12955 415 }
12956
12957 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12958 // This is only updated when the scripts have been recompiled.
12959 // They should all match each other, but there may have been bugs causing this field
12960 // to not always be set so take the largest one.
12961 415 std::optional<word> zscript_version;
12962
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 215 times.
415 if (s_version >= 16)
12963 {
12964
2/2
✓ Branch 0 taken 9975 times.
✓ Branch 1 taken 215 times.
10190 for (auto script : read_scripts)
12965 {
12966 // Scripts with "0" were saved in a version prior to this field being set.
12967 // See https://discord.com/channels/876899628556091432/1368485306394738718
12968
2/2
✓ Branch 0 taken 9882 times.
✓ Branch 1 taken 93 times.
9975 word ffscript_v = script->meta.ffscript_v == 0 ? 16 : script->meta.ffscript_v;
12969
2/2
✓ Branch 0 taken 9779 times.
✓ Branch 1 taken 196 times.
9975 if (!zscript_version.has_value())
12970 196 zscript_version = ffscript_v;
12971
1/2
✓ Branch 0 taken 9779 times.
✗ Branch 1 not taken.
9779 else if (ffscript_v > zscript_version.value())
12972 zscript_version = ffscript_v;
12973 }
12974
12975
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 19 times.
215 if (!zscript_version.has_value())
12976 19 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12977 215 }
12978 415 setZScriptVersion(zscript_version.value_or(s_version));
12979 415 read_scripts.clear();
12980
12981 415 return 0;
12982 415 }
12983
12984 void(*reset_scripts_hook)();
12985
12986 497 void reset_scripts()
12987 {
12988 // We can't modify the script data while jit threads are possibly compiling them.
12989
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 486 times.
497 if (reset_scripts_hook)
12990 486 reset_scripts_hook();
12991
12992
2/2
✓ Branch 0 taken 254464 times.
✓ Branch 1 taken 497 times.
254961 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12993 {
12994
1/2
✓ Branch 0 taken 254464 times.
✗ Branch 1 not taken.
254464 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12995 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12996 254464 }
12997
12998
2/2
✓ Branch 0 taken 254464 times.
✓ Branch 1 taken 497 times.
254961 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12999 {
13000
1/2
✓ Branch 0 taken 254464 times.
✗ Branch 1 not taken.
254464 if (ffscripts[i])
13001 254464 ffscripts[i]->disable();
13002 else
13003 ffscripts[i] = new script_data(ScriptType::FFC, i);
13004 254464 }
13005
13006
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13007 {
13008
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (itemscripts[i])
13009 127232 itemscripts[i]->disable();
13010 else
13011 itemscripts[i] = new script_data(ScriptType::Item, i);
13012 127232 }
13013
13014
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13015 {
13016
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (guyscripts[i])
13017 127232 guyscripts[i]->disable();
13018 else
13019 guyscripts[i] = new script_data(ScriptType::NPC, i);
13020 127232 }
13021
13022
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13023 {
13024
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (screenscripts[i])
13025 127232 screenscripts[i]->disable();
13026 else
13027 screenscripts[i] = new script_data(ScriptType::Screen, i);
13028 127232 }
13029
13030
2/2
✓ Branch 0 taken 3976 times.
✓ Branch 1 taken 497 times.
4473 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13031 {
13032
1/2
✓ Branch 0 taken 3976 times.
✗ Branch 1 not taken.
3976 if (globalscripts[i])
13033 3976 globalscripts[i]->disable();
13034 else
13035 globalscripts[i] = new script_data(ScriptType::Global, i);
13036 3976 }
13037
13038
2/2
✓ Branch 0 taken 2485 times.
✓ Branch 1 taken 497 times.
2982 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
13039 {
13040
1/2
✓ Branch 0 taken 2485 times.
✗ Branch 1 not taken.
2485 if (playerscripts[i])
13041 2485 playerscripts[i]->disable();
13042 else
13043 playerscripts[i] = new script_data(ScriptType::Hero, i);
13044 2485 }
13045
13046
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13047 {
13048
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (lwpnscripts[i])
13049 127232 lwpnscripts[i]->disable();
13050 else
13051 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
13052 127232 }
13053
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13054 {
13055
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (ewpnscripts[i])
13056 127232 ewpnscripts[i]->disable();
13057 else
13058 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
13059 127232 }
13060
13061
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13062 {
13063
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (dmapscripts[i])
13064 127232 dmapscripts[i]->disable();
13065 else
13066 dmapscripts[i] = new script_data(ScriptType::DMap, i);
13067 127232 }
13068
2/2
✓ Branch 0 taken 127232 times.
✓ Branch 1 taken 497 times.
127729 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13069 {
13070
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (itemspritescripts[i])
13071 127232 itemspritescripts[i]->disable();
13072 else
13073 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
13074 127232 }
13075
2/2
✓ Branch 0 taken 254464 times.
✓ Branch 1 taken 497 times.
254961 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13076 {
13077
1/2
✓ Branch 0 taken 254464 times.
✗ Branch 1 not taken.
254464 if (comboscripts[i])
13078 254464 comboscripts[i]->disable();
13079 else
13080 comboscripts[i] = new script_data(ScriptType::Combo, i);
13081 254464 }
13082
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 127232 times.
127729 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
13083 {
13084
1/2
✓ Branch 0 taken 127232 times.
✗ Branch 1 not taken.
127232 if (subscreenscripts[i])
13085 127232 subscreenscripts[i]->disable();
13086 else
13087 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
13088 127232 }
13089 497 }
13090
13091 // 3.0+ calls this.
13092 148 int32_t read_quest_zasm(PACKFILE *f, word s_version)
13093 {
13094 int32_t num_commands;
13095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_igetl(&num_commands,f))
13096 return qe_invalid;
13097 #ifdef ZC_FUZZ
13098 const int32_t command_limit = 300000;
13099 #else
13100 148 const int32_t command_limit = 25000000;
13101 #endif
13102
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 148 times.
148 if (num_commands < 0 || num_commands > command_limit)
13103 return qe_invalid;
13104
13105 148 std::vector<ffscript> zasm;
13106
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 zasm.reserve(num_commands);
13107
2/2
✓ Branch 0 taken 6117609 times.
✓ Branch 1 taken 148 times.
6117757 for(int32_t j=0; j<num_commands; j++)
13108 {
13109
1/2
✓ Branch 0 taken 6117609 times.
✗ Branch 1 not taken.
6117609 ffscript temp_script;
13110
2/4
✓ Branch 0 taken 6117609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6117609 times.
✗ Branch 3 not taken.
6117609 if(!p_igetw(&(temp_script.command),f))
13111 return qe_invalid;
13112
13113
2/4
✓ Branch 0 taken 6117609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6117609 times.
✗ Branch 3 not taken.
6117609 if(!p_igetl(&(temp_script.arg1),f))
13114 return qe_invalid;
13115
13116
2/4
✓ Branch 0 taken 6117609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6117609 times.
✗ Branch 3 not taken.
6117609 if(!p_igetl(&(temp_script.arg2),f))
13117 return qe_invalid;
13118
13119
2/4
✓ Branch 0 taken 6117609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6117609 times.
✗ Branch 3 not taken.
6117609 if(!p_igetl(&(temp_script.arg3),f))
13120 return qe_invalid;
13121
13122 6117609 uint32_t sz = 0;
13123
2/4
✓ Branch 0 taken 6117609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6117609 times.
✗ Branch 3 not taken.
6117609 if(!p_igetl(&sz,f))
13124 return qe_invalid;
13125
2/2
✓ Branch 0 taken 50357 times.
✓ Branch 1 taken 6067252 times.
6117609 if(sz) //string found
13126 {
13127
1/2
✓ Branch 0 taken 50357 times.
✗ Branch 1 not taken.
50357 temp_script.strptr = new std::string();
13128 char dummy;
13129
2/2
✓ Branch 0 taken 985457 times.
✓ Branch 1 taken 50357 times.
1035814 for(size_t q = 0; q < sz; ++q)
13130 {
13131
2/4
✓ Branch 0 taken 985457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 985457 times.
✗ Branch 3 not taken.
985457 if(!p_getc(&dummy,f))
13132 return qe_invalid;
13133
1/2
✓ Branch 0 taken 985457 times.
✗ Branch 1 not taken.
985457 temp_script.strptr->push_back(dummy);
13134 985457 }
13135 50357 }
13136
2/4
✓ Branch 0 taken 6117609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6117609 times.
✗ Branch 3 not taken.
6117609 if(!p_igetl(&sz,f))
13137 return qe_invalid;
13138
2/2
✓ Branch 0 taken 8795 times.
✓ Branch 1 taken 6108814 times.
6117609 if(sz) //vector found
13139 {
13140
1/2
✓ Branch 0 taken 8795 times.
✗ Branch 1 not taken.
8795 temp_script.vecptr = new std::vector<int32_t>();
13141 int32_t dummy;
13142
2/2
✓ Branch 0 taken 55395 times.
✓ Branch 1 taken 8795 times.
64190 for(size_t q = 0; q < sz; ++q)
13143 {
13144
2/4
✓ Branch 0 taken 55395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55395 times.
✗ Branch 3 not taken.
55395 if(!p_igetl(&dummy,f))
13145 return qe_invalid;
13146
1/2
✓ Branch 0 taken 55395 times.
✗ Branch 1 not taken.
55395 temp_script.vecptr->push_back(dummy);
13147 55395 }
13148 8795 }
13149
1/2
✓ Branch 0 taken 6117609 times.
✗ Branch 1 not taken.
6117609 zasm.emplace_back(std::move(temp_script));
13150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6117609 times.
6117609 }
13151
13152
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 assert(zasm_scripts.empty());
13153 148 zasm_script_id id = zasm_scripts.size();
13154
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 148 times.
148 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
13155
13156 148 return 0;
13157 148 }
13158
13159 260735 int32_t read_one_zmeta(PACKFILE *f, zasm_meta& temp_meta, word zmeta_version)
13160 {
13161 260735 char b33[34] = { 0 };
13162 260735 b33[33] = 0;
13163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260735 times.
260735 if(!p_igetw(&(temp_meta.zasm_v),f))
13164 return qe_invalid;
13165
1/2
✓ Branch 0 taken 260735 times.
✗ Branch 1 not taken.
260735 if(!p_igetw(&(temp_meta.meta_v),f))
13166 return qe_invalid;
13167
1/2
✓ Branch 0 taken 260735 times.
✗ Branch 1 not taken.
260735 if(!p_igetw(&(temp_meta.ffscript_v),f))
13168 return qe_invalid;
13169
1/2
✓ Branch 0 taken 260735 times.
✗ Branch 1 not taken.
260735 if(!p_getc(&(temp_meta.script_type),f))
13170 return qe_invalid;
13171
13172
2/2
✓ Branch 0 taken 2085112 times.
✓ Branch 1 taken 260735 times.
2345847 for(int32_t q = 0; q < 8; ++q)
13173 {
13174
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1941232 times.
2085112 if(zmeta_version < 3)
13175 {
13176
2/2
✓ Branch 0 taken 4748040 times.
✓ Branch 1 taken 143880 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13177 {
13178
1/2
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13179 {
13180 return qe_invalid;
13181 }
13182 4748040 }
13183 143880 temp_meta.run_idens[q].assign(b33);
13184 143880 }
13185 else
13186 {
13187
1/2
✓ Branch 0 taken 1941232 times.
✗ Branch 1 not taken.
1941232 if(!p_getcstr(&temp_meta.run_idens[q],f))
13188 {
13189 return qe_invalid;
13190 }
13191 }
13192 2085112 }
13193
13194
2/2
✓ Branch 0 taken 2085112 times.
✓ Branch 1 taken 260735 times.
2345847 for(int32_t q = 0; q < 8; ++q)
13195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2085112 times.
2085112 if(!p_getc(&(temp_meta.run_types[q]),f))
13196 return qe_invalid;
13197
13198
1/2
✓ Branch 0 taken 260735 times.
✗ Branch 1 not taken.
260735 if(!p_getc(&(temp_meta.flags),f))
13199 return qe_invalid;
13200
13201
1/2
✓ Branch 0 taken 260735 times.
✗ Branch 1 not taken.
260735 if(!p_igetw(&(temp_meta.compiler_v1),f))
13202 return qe_invalid;
13203
1/2
✓ Branch 0 taken 260735 times.
✗ Branch 1 not taken.
260735 if(!p_igetw(&(temp_meta.compiler_v2),f))
13204 return qe_invalid;
13205
1/2
✓ Branch 0 taken 260735 times.
✗ Branch 1 not taken.
260735 if(!p_igetw(&(temp_meta.compiler_v3),f))
13206 return qe_invalid;
13207
1/2
✓ Branch 0 taken 260735 times.
✗ Branch 1 not taken.
260735 if(!p_igetw(&(temp_meta.compiler_v4),f))
13208 return qe_invalid;
13209
13210
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 242750 times.
260735 if(zmeta_version == 2)
13211 {
13212
2/2
✓ Branch 0 taken 593505 times.
✓ Branch 1 taken 17985 times.
611490 for(int32_t c = 0; c < 33; ++c)
13213 {
13214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 593505 times.
593505 if(!p_getc(&b33[c],f))
13215 {
13216 return qe_invalid;
13217 }
13218 593505 }
13219 17985 temp_meta.script_name.assign(b33);
13220
13221
2/2
✓ Branch 0 taken 593505 times.
✓ Branch 1 taken 17985 times.
611490 for(int32_t c = 0; c < 33; ++c)
13222 {
13223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 593505 times.
593505 if(!p_getc(&b33[c],f))
13224 {
13225 return qe_invalid;
13226 }
13227 593505 }
13228 17985 temp_meta.author.assign(b33);
13229 17985 }
13230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242750 times.
242750 else if(zmeta_version > 2)
13231 {
13232
1/2
✓ Branch 0 taken 242750 times.
✗ Branch 1 not taken.
242750 if(!p_getcstr(&temp_meta.script_name,f))
13233 return qe_invalid;
13234
1/2
✓ Branch 0 taken 242750 times.
✗ Branch 1 not taken.
242750 if(!p_getcstr(&temp_meta.author,f))
13235 return qe_invalid;
13236 242750 word num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13237 242750 string tmpstr;
13238
2/2
✓ Branch 0 taken 226165 times.
✓ Branch 1 taken 16585 times.
242750 if (zmeta_version < 6)
13239 {
13240
2/2
✓ Branch 0 taken 226165 times.
✓ Branch 1 taken 2261650 times.
2487815 for(auto q = 0; q < num_meta_attrib; ++q)
13241 {
13242
2/4
✓ Branch 0 taken 2261650 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2261650 times.
✗ Branch 3 not taken.
2261650 if(!p_getcstr(&temp_meta.attributes[q],f))
13243 return qe_invalid;
13244
2/4
✓ Branch 0 taken 2261650 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2261650 times.
✗ Branch 3 not taken.
2261650 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13245 return qe_invalid;
13246 2261650 }
13247
2/2
✓ Branch 0 taken 1809320 times.
✓ Branch 1 taken 226165 times.
2035485 for(auto q = 0; q < 8; ++q)
13248 {
13249
2/4
✓ Branch 0 taken 1809320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1809320 times.
✗ Branch 3 not taken.
1809320 if(!p_getcstr(&tmpstr,f))
13250 return qe_invalid;
13251
2/2
✓ Branch 0 taken 452330 times.
✓ Branch 1 taken 1356990 times.
1809320 if (8+q >= num_meta_attrib || !tmpstr.empty())
13252
2/2
✓ Branch 0 taken 1357038 times.
✓ Branch 1 taken 48 times.
1356990 temp_meta.attributes[8+q] = tmpstr;
13253
3/4
✓ Branch 0 taken 1809320 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 1809320 times.
✗ Branch 3 not taken.
1809368 if(!p_getwstr(&tmpstr,f))
13254 return qe_invalid;
13255
4/4
✓ Branch 0 taken 452330 times.
✓ Branch 1 taken 1356990 times.
✓ Branch 2 taken 452296 times.
✓ Branch 3 taken 34 times.
1809320 if (8+q >= num_meta_attrib || !tmpstr.empty())
13256
1/2
✓ Branch 0 taken 1357024 times.
✗ Branch 1 not taken.
1357024 temp_meta.attributes_help[8+q] = tmpstr;
13257 1809320 }
13258
2/2
✓ Branch 0 taken 1809320 times.
✓ Branch 1 taken 226165 times.
2035485 for(auto q = 0; q < 8; ++q)
13259 {
13260
2/4
✓ Branch 0 taken 1809320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1809320 times.
✗ Branch 3 not taken.
1809320 if(!p_getcstr(&temp_meta.attributes[16+q],f))
13261 return qe_invalid;
13262
2/4
✓ Branch 0 taken 1809320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1809320 times.
✗ Branch 3 not taken.
1809320 if(!p_getwstr(&temp_meta.attributes_help[16+q],f))
13263 return qe_invalid;
13264 1809320 }
13265 226165 }
13266 else
13267 {
13268
3/4
✓ Branch 0 taken 16489 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 16489 times.
✗ Branch 3 not taken.
16585 if (!p_igetw(&num_meta_attrib, f))
13269 return qe_invalid;
13270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16489 times.
16489 if (num_meta_attrib > NUM_ZMETA_ATTRIBUTES)
13271 return qe_invalid;
13272
2/2
✓ Branch 0 taken 395736 times.
✓ Branch 1 taken 16489 times.
412225 for(auto q = 0; q < num_meta_attrib; ++q)
13273 {
13274
2/4
✓ Branch 0 taken 395736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 395736 times.
✗ Branch 3 not taken.
395736 if(!p_getcstr(&temp_meta.attributes[q],f))
13275 return qe_invalid;
13276
2/4
✓ Branch 0 taken 395736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 395736 times.
✗ Branch 3 not taken.
395736 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13277 return qe_invalid;
13278 395736 }
13279 }
13280
13281
2/2
✓ Branch 0 taken 3882464 times.
✓ Branch 1 taken 242654 times.
4125118 for(auto q = 0; q < 16; ++q)
13282 {
13283
2/4
✓ Branch 0 taken 3882464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3882464 times.
✗ Branch 3 not taken.
3882464 if(!p_getcstr(&temp_meta.usrflags[q],f))
13284 return qe_invalid;
13285
2/4
✓ Branch 0 taken 3882464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3882464 times.
✗ Branch 3 not taken.
3882464 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13286 return qe_invalid;
13287 3882464 }
13288
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 242654 times.
242846 }
13289
13290
2/2
✓ Branch 0 taken 242654 times.
✓ Branch 1 taken 17985 times.
260639 if(zmeta_version > 3)
13291 {
13292
2/2
✓ Branch 0 taken 1941232 times.
✓ Branch 1 taken 242654 times.
2183886 for(auto q = 0; q < 8; ++q)
13293 {
13294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1941232 times.
1941232 if(!p_getcstr(&temp_meta.initd[q],f))
13295 return qe_invalid;
13296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1941232 times.
1941232 if(!p_getwstr(&temp_meta.initd_help[q],f))
13297 return qe_invalid;
13298 1941232 }
13299
2/2
✓ Branch 0 taken 1941232 times.
✓ Branch 1 taken 242654 times.
2183886 for(auto q = 0; q < 8; ++q)
13300 {
13301
1/2
✓ Branch 0 taken 1941232 times.
✗ Branch 1 not taken.
1941232 if(!p_getc(&temp_meta.initd_type[q],f))
13302 return qe_invalid;
13303 1941232 }
13304 242654 }
13305 else
13306 {
13307
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13308 143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13309 }
13310
13311 260639 return 0;
13312 260831 }
13313 1132643 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13314 {
13315 ASSERT(script);
13316
2/2
✓ Branch 0 taken 562399 times.
✓ Branch 1 taken 570244 times.
1132643 if(s_version < 27)
13317 562399 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
13318
13319 char exists;
13320
1/2
✓ Branch 0 taken 570244 times.
✗ Branch 1 not taken.
570244 if (!p_getc(&exists, f))
13321 return qe_invalid;
13322
2/2
✓ Branch 0 taken 6840 times.
✓ Branch 1 taken 563404 times.
570244 if (!exists)
13323 {
13324 563404 script->disable();
13325 563404 return 0;
13326 }
13327
13328 //Read meta
13329 {
13330 6840 zasm_meta temp_meta;
13331
2/4
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6840 times.
6840 if (auto ret = read_one_zmeta(f, temp_meta, zmeta_version))
13332 return ret;
13333
1/2
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
6840 script->meta = temp_meta;
13334
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6840 times.
6840 }
13335
1/2
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
6840 if(!p_igetl(&script->pc, f))
13336 return qe_invalid;
13337
1/2
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
6840 if(!p_igetl(&script->end_pc, f))
13338 return qe_invalid;
13339
13340
1/2
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
6840 if (script == &fake_script_data)
13341 return 0;
13342
13343
1/2
✓ Branch 0 taken 6840 times.
✗ Branch 1 not taken.
6840 assert(zasm_scripts.size() == 1);
13344 6840 auto& zs = zasm_scripts[0];
13345 6840 script->zasm_script = zs;
13346
13347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6840 times.
6840 if (script->valid())
13348 {
13349 6840 zs->script_datas.push_back(script);
13350 6840 read_scripts.push_back(script);
13351 6840 }
13352
13353 6840 return 0;
13354 1132643 }
13355
13356 562399 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13357 {
13358 562399 int32_t num_commands=1000;
13359
13360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 562399 times.
562399 if(s_version>=2)
13361 {
13362
1/2
✓ Branch 0 taken 562399 times.
✗ Branch 1 not taken.
562399 if(!p_igetl(&num_commands,f))
13363 {
13364 return qe_invalid;
13365 }
13366 562399 }
13367
13368 #ifdef ZC_FUZZ
13369 const int32_t command_limit = 300000;
13370 #else
13371 562399 const int32_t command_limit = 10000000;
13372 #endif
13373
2/4
✓ Branch 0 taken 562399 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 562399 times.
562399 if (num_commands < 0 || num_commands > command_limit)
13374 {
13375 return qe_invalid;
13376 }
13377
13378 562399 std::vector<ffscript> zasm;
13379
1/2
✓ Branch 0 taken 562399 times.
✗ Branch 1 not taken.
562399 zasm.reserve(num_commands);
13380
13381
2/2
✓ Branch 0 taken 253799 times.
✓ Branch 1 taken 308600 times.
562399 if(s_version >= 16)
13382 {
13383
1/2
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
253799 zasm_meta temp_meta;
13384
2/4
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253799 times.
✗ Branch 3 not taken.
253799 if (auto ret = read_one_zmeta(f, temp_meta, zmeta_version))
13385 return ret;
13386
1/2
✓ Branch 0 taken 253799 times.
✗ Branch 1 not taken.
253799 script->meta = temp_meta;
13387
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 253799 times.
✓ Branch 2 taken 308600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 308600 times.
✗ Branch 5 not taken.
562399 } else script->meta = {};
13388
13389
2/2
✓ Branch 0 taken 74674 times.
✓ Branch 1 taken 106043960 times.
106118634 for(int32_t j=0; j<num_commands; j++)
13390 {
13391
1/2
✓ Branch 0 taken 106043960 times.
✗ Branch 1 not taken.
106043960 auto& sc = zasm.emplace_back();
13392
2/4
✓ Branch 0 taken 106043960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106043960 times.
✗ Branch 3 not taken.
106043960 if(!p_igetw(&sc.command,f))
13393 {
13394 return qe_invalid;
13395 }
13396
13397
2/2
✓ Branch 0 taken 105556235 times.
✓ Branch 1 taken 487725 times.
106043960 if(sc.command == 0xFFFF)
13398 487725 break;
13399 else
13400 {
13401
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg1,f))
13402 {
13403 return qe_invalid;
13404 }
13405
13406
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg2,f))
13407 {
13408 return qe_invalid;
13409 }
13410
13411
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 104508488 times.
105556235 if(s_version >= 24)
13412
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13413 return qe_invalid;
13414
13415
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 97334198 times.
105556235 if(s_version >= 21)
13416 {
13417 8222037 uint32_t sz = 0;
13418
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13419 {
13420 return qe_invalid;
13421 }
13422
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13423 {
13424
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13425 char dummy;
13426
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13427 {
13428
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13429 {
13430 return qe_invalid;
13431 }
13432
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13433 1165008 }
13434 19400 }
13435
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13436 {
13437 return qe_invalid;
13438 }
13439
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13440 {
13441
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13442 int32_t dummy;
13443
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13444 {
13445
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13446 {
13447 return qe_invalid;
13448 }
13449
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13450 11526 }
13451 933 }
13452 8222037 }
13453 }
13454 105556235 }
13455
13456
2/2
✓ Branch 0 taken 494047 times.
✓ Branch 1 taken 68352 times.
562399 if (script == &fake_script_data)
13457 68352 return 0;
13458
13459 // If the first command is unknown, invalidate the whole thing.
13460 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13461
5/6
✓ Branch 0 taken 424749 times.
✓ Branch 1 taken 69298 times.
✓ Branch 2 taken 412772 times.
✓ Branch 3 taken 11977 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 412772 times.
494047 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13462 {
13463 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13464 zasm.clear();
13465 }
13466
13467 494047 zasm_script_id id = zasm_scripts.size();
13468
3/6
✓ Branch 0 taken 494047 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494047 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 494047 times.
✗ Branch 5 not taken.
494047 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13469 494047 script->zasm_script = zs;
13470 494047 script->pc = 0;
13471 494047 script->end_pc = zs->size;
13472
3/4
✓ Branch 0 taken 494047 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11977 times.
✓ Branch 3 taken 482070 times.
494047 if (script->valid())
13473 {
13474
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 zs->script_datas.push_back(script);
13475
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 read_scripts.push_back(script);
13476 11977 }
13477
13478 494047 return 0;
13479 562399 }
13480
13481 extern SAMPLE customsfxdata[WAV_COUNT];
13482 extern uint8_t customsfxflag[WAV_COUNT>>3];
13483 extern int32_t sfxdat;
13484 extern DATAFILE *sfxdata;
13485 const char *old_sfx_string[Z35] =
13486 {
13487 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13488 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13489 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13490 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13491 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13492 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13493 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13494 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13495 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13496 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13497 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13498 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13499 };
13500 char *sfx_string[WAV_COUNT];
13501
13502 415 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13503 {
13504 //these are here to bypass compiler warnings about unused arguments
13505 415 Header=Header;
13506
13507 int32_t dummy;
13508 415 word s_version=0;
13509 //int32_t ret;
13510 415 SAMPLE temp_sample = {};
13511 415 temp_sample.loop_start=0;
13512 415 temp_sample.loop_end=0;
13513 415 temp_sample.param=0;
13514
13515 //section version info
13516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(!p_igetw(&s_version,f))
13517 {
13518 return qe_invalid;
13519 }
13520
13521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (s_version > V_SFX)
13522 return qe_version;
13523
13524 415 FFCore.quest_format[vSFX] = s_version;
13525
13526
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!read_deprecated_section_cversion(f))
13527 {
13528 return qe_invalid;
13529 }
13530
13531 //section size
13532
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy,f))
13533 {
13534 return qe_invalid;
13535 }
13536
13537 /* HIGHLY UNORTHODOX UPDATING THING, by L
13538 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13539 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13540 * changing from 1 to 2.
13541 */
13542
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version < 2)
13543 set_qr(qr_GOTOLESSNOTEQUAL,1);
13544
13545 /* End highly unorthodox updating thing */
13546
13547 415 int32_t wavcount = WAV_COUNT;
13548
13549
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version < 6)
13550 wavcount = 128;
13551
13552 uint8_t tempflag[WAV_COUNT>>3];
13553
13554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(s_version < 4)
13555 {
13556 memset(tempflag, 0xFF, WAV_COUNT>>3);
13557 }
13558 else
13559 {
13560
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version < 6)
13561 memset(tempflag, 0, WAV_COUNT>>3);
13562
13563
2/2
✓ Branch 0 taken 13280 times.
✓ Branch 1 taken 415 times.
13695 for(int32_t i=0; i<(wavcount>>3); i++)
13564 {
13565 13280 p_getc(&tempflag[i], f);
13566 13280 }
13567
13568 }
13569
13570
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(s_version>4)
13571 {
13572
2/2
✓ Branch 0 taken 105825 times.
✓ Branch 1 taken 415 times.
106240 for(int32_t i=1; i<WAV_COUNT; i++)
13573 {
13574 105825 sprintf(sfx_string[i],"s%03d",i);
13575
13576
2/2
✓ Branch 0 taken 80925 times.
✓ Branch 1 taken 24900 times.
105825 if((i<Z35))
13577 24900 strcpy(sfx_string[i], old_sfx_string[i-1]);
13578
13579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105825 times.
105825 if(i>=wavcount)
13580 continue;
13581
2/2
✓ Branch 0 taken 23150 times.
✓ Branch 1 taken 82675 times.
105825 if(get_bit(tempflag, i-1))
13582 {
13583 char tempname[36];
13584
13585
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!pfread(tempname, 36, f))
13586 {
13587 return qe_invalid;
13588 }
13589
13590 23150 sfx_string[i][0] = '\0';
13591 23150 strncat(sfx_string[i], tempname, 36 - 1);
13592 23150 }
13593 else
13594 {
13595 82675 sprintf(sfx_string[i],"s%03d",i);
13596
13597
2/2
✓ Branch 0 taken 72985 times.
✓ Branch 1 taken 9690 times.
82675 if(i<Z35)
13598 9690 strcpy(sfx_string[i], old_sfx_string[i-1]);
13599 82675 sfx_string[i][35] = 0; //Force NULL Termination
13600 }
13601 105825 }
13602 415 }
13603 else
13604 {
13605 for(int32_t i=1; i<WAV_COUNT; i++)
13606 {
13607 sprintf(sfx_string[i],"s%03d",i);
13608
13609 if(i<Z35)
13610 strcpy(sfx_string[i], old_sfx_string[i-1]);
13611 }
13612 }
13613
13614 //finally... section data
13615
2/2
✓ Branch 0 taken 105825 times.
✓ Branch 1 taken 415 times.
106240 for(int32_t i=1; i<wavcount; i++)
13616 {
13617
2/2
✓ Branch 0 taken 23150 times.
✓ Branch 1 taken 82675 times.
105825 if(get_bit(tempflag, i-1))
13618 {
13619
13620
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&dummy,f))
13621 {
13622 return qe_invalid;
13623 }
13624
13625 23150 (temp_sample.bits) = dummy;
13626
13627
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&dummy,f))
13628 {
13629 return qe_invalid;
13630 }
13631
13632 23150 (temp_sample.stereo) = dummy;
13633
13634
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&dummy,f))
13635 {
13636 return qe_invalid;
13637 }
13638
13639 23150 (temp_sample.freq) = dummy;
13640
13641
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&dummy,f))
13642 {
13643 return qe_invalid;
13644 }
13645
13646 23150 (temp_sample.priority) = dummy;
13647
13648
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&(temp_sample.len),f))
13649 {
13650 return qe_invalid;
13651 }
13652
13653
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&(temp_sample.loop_start),f))
13654 {
13655 return qe_invalid;
13656 }
13657
13658
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&(temp_sample.loop_end),f))
13659 {
13660 return qe_invalid;
13661 }
13662
13663
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(!p_igetl(&(temp_sample.param),f))
13664 {
13665 return qe_invalid;
13666 }
13667
13668 23150 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13669 #ifdef ZC_FUZZ
13670 const int32_t sfx_limit = 100000;
13671 if (len < 0 || len > sfx_limit)
13672 {
13673 return qe_invalid;
13674 }
13675 #endif
13676 23150 temp_sample.data = calloc(len,1);
13677
13678
1/2
✓ Branch 0 taken 23150 times.
✗ Branch 1 not taken.
23150 if(s_version < 3)
13679 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13680
13681 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23150 times.
23150 if(s_version < 2)
13683 {
13684 if(!pfread(temp_sample.data, len,f))
13685 {
13686 return qe_invalid;
13687 }
13688 }
13689 else
13690 {
13691 //re-endianfy the data
13692 23150 int32_t wordstoread = len / sizeof(word);
13693
13694
2/2
✓ Branch 0 taken 669182603 times.
✓ Branch 1 taken 23150 times.
669205753 for(int32_t j=0; j<wordstoread; j++)
13695 {
13696 word temp;
13697
13698
1/2
✓ Branch 0 taken 669182603 times.
✗ Branch 1 not taken.
669182603 if(!p_igetw(&temp, f))
13699 {
13700 return qe_invalid;
13701 }
13702
13703 669182603 ((word *)temp_sample.data)[j] = temp;
13704 669182603 }
13705 }
13706 23150 }
13707
2/2
✓ Branch 0 taken 9690 times.
✓ Branch 1 taken 72985 times.
82675 else if(i < Z35)
13708 {
13709 9690 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13710 9690 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13711 9690 set_bit(tempflag, i-1, 1);
13712 9690 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13713 9690 temp_sample.data = calloc(len,1);
13714 9690 memcpy(temp_sample.data, datsamp->data, len);
13715 9690 }
13716 72985 else continue;
13717
13718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32840 times.
32840 if(customsfxdata[i].data!=NULL)
13719 {
13720 // delete [] customsfxdata[i].data;
13721 32840 free(customsfxdata[i].data);
13722 32840 }
13723
13724 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13725 32840 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13726 32840 customsfxdata[i].data = calloc(len2,1);
13727 32840 customsfxdata[i].bits = temp_sample.bits;
13728 32840 customsfxdata[i].stereo = temp_sample.stereo;
13729 32840 customsfxdata[i].freq = temp_sample.freq;
13730 32840 customsfxdata[i].priority = temp_sample.priority;
13731 32840 customsfxdata[i].len = temp_sample.len;
13732 32840 customsfxdata[i].loop_start = temp_sample.loop_start;
13733 32840 customsfxdata[i].loop_end = temp_sample.loop_end;
13734 32840 customsfxdata[i].param = temp_sample.param;
13735 32840 int32_t cpylen = len2;
13736
13737
1/2
✓ Branch 0 taken 32840 times.
✗ Branch 1 not taken.
32840 if(s_version<3)
13738 {
13739 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13740 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13741 }
13742
13743 32840 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13744
13745 32840 free(temp_sample.data);
13746 32840 }
13747
13748 415 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13749
13750 415 sfxdat=0;
13751 415 return 0;
13752 415 }
13753
13754 497 void setupsfx()
13755 {
13756
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=1; i<WAV_COUNT; i++)
13757 {
13758 126735 sprintf(sfx_string[i],"s%03d",i);
13759
13760
2/2
✓ Branch 0 taken 96915 times.
✓ Branch 1 taken 29820 times.
126735 if(i<Z35)
13761 {
13762 29820 strcpy(sfx_string[i], old_sfx_string[i-1]);
13763 29820 }
13764
13765 126735 memset(customsfxflag, 0, WAV_COUNT>>3);
13766
13767 126735 int32_t j=i;
13768
13769
2/2
✓ Branch 0 taken 30317 times.
✓ Branch 1 taken 96418 times.
126735 if(i>Z35)
13770 {
13771 96418 i=Z35;
13772 96418 }
13773
13774 126735 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13775
13776
2/2
✓ Branch 0 taken 97665 times.
✓ Branch 1 taken 29070 times.
126735 if(customsfxdata[j].data!=NULL)
13777 {
13778 // delete [] customsfxdata[j].data;
13779 29070 free(customsfxdata[j].data);
13780 29070 }
13781
13782 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13783 126735 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13784 126735 customsfxdata[j].bits = temp_sample->bits;
13785 126735 customsfxdata[j].stereo = temp_sample->stereo;
13786 126735 customsfxdata[j].freq = temp_sample->freq;
13787 126735 customsfxdata[j].priority = temp_sample->priority;
13788 126735 customsfxdata[j].len = temp_sample->len;
13789 126735 customsfxdata[j].loop_start = temp_sample->loop_start;
13790 126735 customsfxdata[j].loop_end = temp_sample->loop_end;
13791 126735 customsfxdata[j].param = temp_sample->param;
13792 126735 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13793 126735 i=j;
13794 126735 }
13795 497 }
13796
13797 extern char *guy_string[eMAXGUYS];
13798 extern const char *old_guy_string[OLDMAXGUYS];
13799
13800 497 int32_t readguys(PACKFILE *f, zquestheader *Header)
13801 {
13802
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if (should_skip) return 0;
13804
13805 dword dummy;
13806 word guy_cversion;
13807 497 word guyversion=0;
13808
13809
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 474 times.
497 if(Header->zelda_version >= 0x193)
13810 {
13811 //section version info
13812
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&guyversion,f))
13813 {
13814 return qe_invalid;
13815 }
13816
13817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (guyversion > V_GUYS)
13818 return qe_version;
13819
13820 474 FFCore.quest_format[vGuys] = guyversion;
13821
13822 // Note: this is the only instance where "cversion" is ever used.
13823
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&guy_cversion,f))
13824 {
13825 return qe_invalid;
13826 }
13827
13828 //section size
13829
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
13830 {
13831 return qe_invalid;
13832 }
13833 474 }
13834
13835
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
497 if(guyversion > 3)
13836 {
13837
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 415 times.
212895 for(int32_t i=0; i<MAXGUYS; i++)
13838 {
13839 char tempname[64];
13840
13841 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13842 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
212480 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13844 {
13845 memset(tempname, 0, sizeof(char)*64);
13846 sprintf(tempname, "e%03d", i);
13847 strcpy(guy_string[i], tempname);
13848
13849 continue;
13850 }
13851
13852
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!pfread(tempname, 64, f))
13853 {
13854 return qe_invalid;
13855 }
13856
13857 // Don't retain names of uneditable enemy entries!
13858 // for version upgrade to 2.5
13859
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
212480 if(guyversion < 23 && i >= 177)
13860 {
13861 // some of the older builds have names such as 'zz123',
13862 // (this order gets messed up with some eXXX and some zzXXX)
13863 // so let's update to the newer naming convection. -Gleeok
13864 char tmpbuf[64];
13865 memset(tmpbuf, 0, sizeof(char)*64);
13866 sprintf(tmpbuf, "zz%03d", i);
13867
13868 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13869 {
13870 memset(tempname, 0, sizeof(char)*64);
13871 sprintf(tempname, "e%03d", i);
13872 }
13873 }
13874
13875
6/6
✓ Branch 0 taken 73455 times.
✓ Branch 1 taken 139025 times.
✓ Branch 2 taken 69720 times.
✓ Branch 3 taken 3735 times.
✓ Branch 4 taken 61045 times.
✓ Branch 5 taken 8675 times.
212480 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13876 {
13877 203805 guy_string[i][0] = '\0';
13878 203805 strncat(guy_string[i], tempname, 64 - 1);
13879 203805 }
13880 else
13881 {
13882 8675 strcpy(guy_string[i],old_guy_string[i]);
13883 }
13884 212480 }
13885 415 }
13886 else
13887 {
13888
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13889 {
13890 41984 sprintf(guy_string[i],"zz%03d",i);
13891 41984 }
13892
13893
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13894 {
13895 14514 strcpy(guy_string[i],old_guy_string[i]);
13896 14514 }
13897 }
13898
13899
13900 //finally... section data
13901 497 init_guys(guyversion); //using default data for now...
13902
13903 // Goriya guy fix
13904
3/6
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
497 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13905 {
13906
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13907 {
13908 60 guysbuf[gGORIYA].tile=130;
13909 60 guysbuf[gGORIYA].e_tile=130;
13910 60 }
13911 82 }
13912
13913
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 if(Header->zelda_version < 0x193)
13914 {
13915
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13916 {
13917 5 guysbuf[eDODONGO].cset=14;
13918 5 guysbuf[eDODONGO].bosspal=spDIG;
13919 5 }
13920 23 }
13921 // Not sure when this first changed, but it's necessary for 2.10, at least
13922 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13923 //2.10 Fixes
13924
3/6
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
497 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13925 {
13926 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13927 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13928 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13929 82 guysbuf[eCENT1].attributes[2] = 1;
13930 82 guysbuf[eCENT2].attributes[2] = 1;
13931 82 }
13932
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
497 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13933 {
13934 497 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13935 497 }
13936
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
497 if(Header->zelda_version <= 0x210)
13937 {
13938 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13939 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13940 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13941 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13942
13943 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13944 82 guysbuf[eBATROBE].attributes[3] = 1;
13945 //guysbuf[eSUMMONER].misc4 = 1;
13946 82 guysbuf[eWWIZ].attributes[3] = 1;
13947 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13948 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13949 82 }
13950
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 12 times.
497 if(Header->zelda_version == 0x190)
13951 {
13952 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13953 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13954 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13955 12 }
13956
13957 // The versions here may not be correct
13958 // zelda_version>=0x211 handled at guyversion<24
13959
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 479 times.
497 if(Header->zelda_version <= 0x190)
13960 {
13961 18 guysbuf[eCENT1].attributes[2] = 0;
13962 18 guysbuf[eCENT2].attributes[2] = 0;
13963 18 guysbuf[eMOLDORM].attributes[1] = 0;
13964 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13965 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13966 18 }
13967
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 64 times.
479 else if(Header->zelda_version <= 0x210)
13968 {
13969 64 guysbuf[eCENT1].attributes[2] = 1;
13970 64 guysbuf[eCENT2].attributes[2] = 1;
13971 64 guysbuf[eMOLDORM].attributes[1] = 0;
13972 64 }
13973
13974
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 82 times.
497 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13975 {
13976 82 guysbuf[eKEESE1].attributes[15] = 120;
13977 82 guysbuf[eKEESE2].attributes[15] = 120;
13978 82 guysbuf[eKEESE3].attributes[15] = 120;
13979 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13980 82 guysbuf[eKEESE1].attributes[16] = 16;
13981 82 guysbuf[eKEESE2].attributes[16] = 16;
13982 82 guysbuf[eKEESE3].attributes[16] = 16;
13983 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13984
13985 82 guysbuf[ePEAHAT].attributes[15] = 80;
13986 82 guysbuf[ePEAHAT].attributes[16] = 16;
13987
13988 82 guysbuf[eGHINI2].attributes[15] = 120;
13989 82 guysbuf[eGHINI2].attributes[16] = 10;
13990
13991
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13992 {
13993 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13994 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13995 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13996 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13997 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13998 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13999 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14000 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14001 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14002 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14003 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14004 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14005 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14006 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14007 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14008 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14009 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14010 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14011 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14012 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14013 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14014 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14015 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14016 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14017 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14018 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14019 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14020 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14021 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14022 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14023 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14024 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14025 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14026 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14027 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14028 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14029 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14030 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14031 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14032 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14033 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14034 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14035 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14036 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14037 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14038 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14039 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14040 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14041 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
14042 66 }
14043 82 }
14044
14045
14046
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 415 times.
497 if(guyversion<=2)
14047 {
14048 82 return readherosprites2(f, guyversion==2?0:-1);
14049 }
14050
14051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(guyversion > 3)
14052 {
14053 415 guydata tempguy;
14054
14055
2/2
✓ Branch 0 taken 212480 times.
✓ Branch 1 taken 415 times.
212895 for(int32_t i=0; i<MAXGUYS; i++)
14056 {
14057
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 23) // May 2012 : 512 max enemies
14058 {
14059 if(i >= OLDBETAMAXGUYS)
14060 {
14061 guysbuf[i].clear();
14062 continue;
14063 }
14064 }
14065
14066 212480 tempguy.clear();
14067
14068 uint32_t flags1;
14069 uint32_t flags2;
14070
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetl(&(flags1),f))
14071 {
14072 return qe_invalid;
14073 }
14074
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetl(&(flags2),f))
14075 {
14076 return qe_invalid;
14077 }
14078 212480 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
14079
14080
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion >= 36 ) //expanded tiles
14081 {
14082
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.tile),f))
14083 {
14084 return qe_invalid;
14085 }
14086 110080 }
14087 else
14088 {
14089
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.tile),f))
14090 {
14091 return qe_invalid;
14092 }
14093 }
14094
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.width),f))
14095 {
14096 return qe_invalid;
14097 }
14098
14099
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.height),f))
14100 {
14101 return qe_invalid;
14102 }
14103
14104
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion >= 36 ) //expanded tiles
14105 {
14106
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.s_tile),f))
14107 {
14108 return qe_invalid;
14109 }
14110 110080 }
14111 else
14112 {
14113
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.s_tile),f))
14114 {
14115 return qe_invalid;
14116 }
14117 }
14118
14119
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.s_width),f))
14120 {
14121 return qe_invalid;
14122 }
14123
14124
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.s_height),f))
14125 {
14126 return qe_invalid;
14127 }
14128
14129
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion >= 36 ) //expanded tiles
14130 {
14131
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.e_tile),f))
14132 {
14133 return qe_invalid;
14134 }
14135 110080 }
14136 else
14137 {
14138
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.e_tile),f))
14139 {
14140 return qe_invalid;
14141 }
14142 }
14143
14144
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.e_width),f))
14145 {
14146 return qe_invalid;
14147 }
14148
14149
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.e_height),f))
14150 {
14151 return qe_invalid;
14152 }
14153
14154
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.hp),f))
14155 {
14156 return qe_invalid;
14157 }
14158
14159
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.type),f))
14160 {
14161 return qe_invalid;
14162 }
14163
14164
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
212480 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14165 {
14166 if(get_qr(qr_NEWENEMYTILES))
14167 {
14168 tempguy.s_tile=tempguy.e_tile+120;
14169 tempguy.s_width=tempguy.e_width;
14170 tempguy.s_height=tempguy.e_height;
14171 }
14172 else tempguy.s_tile=860;
14173 }
14174
14175
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.cset),f))
14176 {
14177 return qe_invalid;
14178 }
14179
14180
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.anim),f))
14181 {
14182 return qe_invalid;
14183 }
14184
14185
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.e_anim),f))
14186 {
14187 return qe_invalid;
14188 }
14189
14190
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.frate),f))
14191 {
14192 return qe_invalid;
14193 }
14194
14195
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.e_frate),f))
14196 {
14197 return qe_invalid;
14198 }
14199
14200
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 13) // April 2009
14201 {
14202 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14203 {
14204 tempguy.frate *= 2;
14205 tempguy.e_frate *= 2;
14206 }
14207 }
14208
14209
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 14) // May 1 2009
14210 {
14211 if(tempguy.anim==a2FRMSLOW)
14212 {
14213 tempguy.anim=a2FRM;
14214 tempguy.frate *= 2;
14215 }
14216
14217 if(tempguy.e_anim==a2FRMSLOW)
14218 {
14219 tempguy.e_anim=a2FRM;
14220 tempguy.e_frate *= 2;
14221 }
14222
14223 if(tempguy.anim==aFLIPSLOW)
14224 {
14225 tempguy.anim=aFLIP;
14226 tempguy.frate *= 2;
14227 }
14228
14229 if(tempguy.e_anim==aFLIPSLOW)
14230 {
14231 tempguy.e_anim=aFLIP;
14232 tempguy.e_frate *= 2;
14233 }
14234
14235 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14236
14237 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14238
14239 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14240 {
14241 tempguy.anim=a4FRM4DIR;
14242 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14243 }
14244
14245 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14246 {
14247 tempguy.e_anim=a4FRM4DIR;
14248 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14249 }
14250 }
14251
14252
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.dp),f))
14253 {
14254 return qe_invalid;
14255 }
14256
14257 //correction for guy fire
14258
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 6)
14259 {
14260 if(i == gFIRE)
14261 tempguy.dp = 2;
14262 }
14263
14264
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.wdp),f))
14265 {
14266 return qe_invalid;
14267 }
14268
14269
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.weapon),f))
14270 {
14271 return qe_invalid;
14272 }
14273
14274 //correction for bosses using triple, "rising" fireballs
14275
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 5)
14276 {
14277 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14278 i == eGOHMA3 || i == eGOHMA4)
14279 {
14280 if(tempguy.weapon == ewFireball)
14281 tempguy.weapon = ewFireball2;
14282 }
14283 }
14284
14285
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.rate),f))
14286 {
14287 return qe_invalid;
14288 }
14289
14290
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.hrate),f))
14291 {
14292 return qe_invalid;
14293 }
14294
14295
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.step),f))
14296 {
14297 return qe_invalid;
14298 }
14299
14300 // HIGHLY UNORTHODOX UPDATING THING, part 2
14301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
212480 if(fixpolsvoice && tempguy.type==eePOLSV)
14302 {
14303 tempguy.step /= 2;
14304 }
14305
14306
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.homing),f))
14307 {
14308 return qe_invalid;
14309 }
14310
14311
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.grumble),f))
14312 {
14313 return qe_invalid;
14314 }
14315
14316
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.item_set),f))
14317 {
14318 return qe_invalid;
14319 }
14320
14321
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14322 {
14323
2/2
✓ Branch 0 taken 2124800 times.
✓ Branch 1 taken 212480 times.
2337280 for (int q = 0; q < 10; ++q)
14324 {
14325
1/2
✓ Branch 0 taken 2124800 times.
✗ Branch 1 not taken.
2124800 if (!p_igetl(&(tempguy.attributes[q]), f))
14326 {
14327 return qe_invalid;
14328 }
14329 2124800 }
14330 212480 }
14331 else
14332 {
14333 int16_t tempMisc;
14334
14335 for(int q=0;q<10;q++)
14336 {
14337 if (!p_igetw(&tempMisc, f))
14338 {
14339 return qe_invalid;
14340 }
14341 tempguy.attributes[q] = tempMisc;
14342 }
14343
14344 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14345 {
14346 if(tempguy.type == eeWIZZ && !(tempguy.attributes[0]))
14347 tempguy.attributes[4] = 74;
14348 }
14349
14350 }
14351
14352
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.bgsfx),f))
14353 {
14354 return qe_invalid;
14355 }
14356
14357
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.bosspal),f))
14358 {
14359 return qe_invalid;
14360 }
14361
14362
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetw(&(tempguy.extend),f))
14363 {
14364 return qe_invalid;
14365 }
14366
14367 //! Enemy Defences
14368
14369 //If a 2.50 quest, use only the 2.5 defences.
14370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
212480 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14371 {
14372
2/2
✓ Branch 0 taken 4037120 times.
✓ Branch 1 taken 212480 times.
4249600 for(int32_t j=0; j<edefLAST; j++)
14373 {
14374
1/2
✓ Branch 0 taken 4037120 times.
✗ Branch 1 not taken.
4037120 if(!p_getc(&(tempguy.defense[j]),f))
14375 {
14376 return qe_invalid;
14377 }
14378 4037120 }
14379 //then copy the generic script defence to all the new script defences
14380
14381 212480 }
14382
14383
14384
14385
14386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212480 times.
212480 if(guyversion >= 18)
14387 {
14388
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.hitsfx),f))
14389 {
14390 return qe_invalid;
14391 }
14392
14393
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_getc(&(tempguy.deadsfx),f))
14394 {
14395 return qe_invalid;
14396 }
14397 212480 }
14398
14399
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion >= 22)
14400 {
14401
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetl(&(tempguy.attributes[10]), f))
14402 {
14403 return qe_invalid;
14404 }
14405
14406
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(!p_igetl(&(tempguy.attributes[11]),f))
14407 {
14408 return qe_invalid;
14409 }
14410 212480 }
14411 else if(guyversion >= 19)
14412 {
14413 int16_t tempMisc;
14414
14415 if(!p_igetw(&tempMisc,f))
14416 {
14417 return qe_invalid;
14418 }
14419
14420 tempguy.attributes[10] = tempMisc;
14421
14422 if(!p_igetw(&tempMisc,f))
14423 {
14424 return qe_invalid;
14425 }
14426
14427 tempguy.attributes[11] = tempMisc;
14428 }
14429
14430 //If a 2.54 or later quest, use all of the defences.
14431
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion > 24) // Add new guyversion conditional statement
14432 {
14433
2/2
✓ Branch 0 taken 2421760 times.
✓ Branch 1 taken 110080 times.
2531840 for(int32_t j=edefLAST; j<edefLAST255; j++)
14434 {
14435
1/2
✓ Branch 0 taken 2421760 times.
✗ Branch 1 not taken.
2421760 if(!p_getc(&(tempguy.defense[j]),f))
14436 {
14437 return qe_invalid;
14438 }
14439 2421760 }
14440 110080 }
14441
14442
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14443 {
14444
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14445 {
14446 1024000 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14447 1024000 }
14448 102400 }
14449
14450 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14451
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion > 25)
14452 {
14453
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.txsz),f))
14454 {
14455 return qe_invalid;
14456 }
14457
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.tysz),f))
14458 {
14459 return qe_invalid;
14460 }
14461
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.hxsz),f))
14462 {
14463 return qe_invalid;
14464 }
14465
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.hysz),f))
14466 {
14467 return qe_invalid;
14468 }
14469
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.hzsz),f))
14470 {
14471 return qe_invalid;
14472 }
14473 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14474
14475 */
14476 110080 }
14477 //More Enemy Editor vars for 2.60
14478
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion > 26)
14479 {
14480
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.hxofs),f))
14481 {
14482 return qe_invalid;
14483 }
14484
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.hyofs),f))
14485 {
14486 return qe_invalid;
14487 }
14488
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.xofs),f))
14489 {
14490 return qe_invalid;
14491 }
14492
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.yofs),f))
14493 {
14494 return qe_invalid;
14495 }
14496
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.zofs),f))
14497 {
14498 return qe_invalid;
14499 }
14500 110080 }
14501
14502
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14503 {
14504 102400 tempguy.wpnsprite = 0;
14505 102400 }
14506
14507
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion > 27)
14508 {
14509
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.wpnsprite),f))
14510 {
14511 return qe_invalid;
14512 }
14513 110080 }
14514
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14515 {
14516 102400 tempguy.SIZEflags = 0;
14517 102400 }
14518
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion > 28)
14519 {
14520
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.SIZEflags),f))
14521 {
14522 return qe_invalid;
14523 }
14524
14525 110080 }
14526
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14527 {
14528 102400 tempguy.frozentile = 0;
14529 102400 tempguy.frozencset = 0;
14530 102400 tempguy.frozenclock = 0;
14531
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14532 102400 }
14533
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion >= 30)
14534 {
14535
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.frozentile),f))
14536 {
14537 return qe_invalid;
14538 }
14539
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.frozencset),f))
14540 {
14541 return qe_invalid;
14542 }
14543
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.frozenclock),f))
14544 {
14545 return qe_invalid;
14546 }
14547
2/2
✓ Branch 0 taken 1100800 times.
✓ Branch 1 taken 110080 times.
1210880 for ( int32_t q = 0; q < 10; q++ ) {
14548
1/2
✓ Branch 0 taken 1100800 times.
✗ Branch 1 not taken.
1100800 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14549 {
14550 return qe_invalid;
14551 }
14552 1100800 }
14553
14554 110080 }
14555
14556
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion >= 34)
14557 {
14558
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetw(&(tempguy.firesfx),f))
14559 {
14560 return qe_invalid;
14561 }
14562
2/2
✓ Branch 0 taken 1871360 times.
✓ Branch 1 taken 110080 times.
1981440 for(int q=15;q<32;++q)
14563 {
14564
1/2
✓ Branch 0 taken 1871360 times.
✗ Branch 1 not taken.
1871360 if(!p_igetl(&(tempguy.attributes[q]),f))
14565 {
14566 return qe_invalid;
14567 }
14568 1871360 }
14569
14570
2/2
✓ Branch 0 taken 3522560 times.
✓ Branch 1 taken 110080 times.
3632640 for ( int32_t q = 0; q < 32; q++ ) {
14571
1/2
✓ Branch 0 taken 3522560 times.
✗ Branch 1 not taken.
3522560 if(!p_igetl(&(tempguy.movement[q]),f))
14572 {
14573 return qe_invalid;
14574 }
14575 3522560 }
14576
2/2
✓ Branch 0 taken 3522560 times.
✓ Branch 1 taken 110080 times.
3632640 for ( int32_t q = 0; q < 32; q++ ) {
14577
1/2
✓ Branch 0 taken 3522560 times.
✗ Branch 1 not taken.
3522560 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14578 {
14579 return qe_invalid;
14580 }
14581 3522560 }
14582
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetw(&(tempguy.script),f))
14583 {
14584 return qe_invalid;
14585 }
14586
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; q++ )
14587 {
14588
1/2
✓ Branch 0 taken 880640 times.
✗ Branch 1 not taken.
880640 if(!p_igetl(&(tempguy.initD[q]),f))
14589 {
14590 return qe_invalid;
14591 }
14592 880640 }
14593
2/2
✓ Branch 0 taken 220160 times.
✓ Branch 1 taken 110080 times.
330240 for ( int32_t q = 0; q < 2; q++ )
14594 {
14595 int32_t temp;
14596
1/2
✓ Branch 0 taken 220160 times.
✗ Branch 1 not taken.
220160 if(!p_igetl(&temp,f))
14597 {
14598 return qe_invalid;
14599 }
14600 220160 }
14601
14602 110080 }
14603
14604
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion >= 37)
14605 {
14606
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.editorflags),f))
14607 {
14608 return qe_invalid;
14609 }
14610 110080 }
14611
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14612
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if(guyversion >= 38)
14613 {
14614
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.attributes[12]),f))
14615 {
14616 return qe_invalid;
14617 }
14618
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.attributes[13]),f))
14619 {
14620 return qe_invalid;
14621 }
14622
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_igetl(&(tempguy.attributes[14]),f))
14623 {
14624 return qe_invalid;
14625 }
14626
14627 110080 }
14628
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion < 38 )
14629 {
14630 102400 tempguy.attributes[12] = 0;
14631 102400 tempguy.attributes[13] = 0;
14632 102400 tempguy.attributes[14] = 0;
14633 102400 }
14634
14635
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if ( guyversion >= 39 )
14636 {
14637
2/2
✓ Branch 0 taken 880640 times.
✓ Branch 1 taken 110080 times.
990720 for ( int32_t q = 0; q < 8; q++ )
14638 {
14639
2/2
✓ Branch 0 taken 57241600 times.
✓ Branch 1 taken 880640 times.
58122240 for ( int32_t w = 0; w < 65; w++ )
14640 {
14641
1/2
✓ Branch 0 taken 57241600 times.
✗ Branch 1 not taken.
57241600 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14642 {
14643 return qe_invalid;
14644 }
14645 57241600 }
14646
2/2
✓ Branch 0 taken 667648 times.
✓ Branch 1 taken 212992 times.
880640 if(guyversion < 54)
14647 {
14648 byte dummybyte;
14649
2/2
✓ Branch 0 taken 13844480 times.
✓ Branch 1 taken 212992 times.
14057472 for ( int32_t w = 0; w < 65; w++ )
14650
1/2
✓ Branch 0 taken 13844480 times.
✗ Branch 1 not taken.
13844480 if(!p_getc(&dummybyte,f))
14651 return qe_invalid;
14652 212992 }
14653 880640 }
14654
14655
14656 110080 }
14657
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion < 39 ) //apply old InitD strings to both
14658 {
14659
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ )
14660 {
14661 819200 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14662 819200 }
14663 102400 }
14664
4/4
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 83456 times.
✓ Branch 3 taken 26624 times.
212480 if ( guyversion >= 40 && guyversion < 54)
14665
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 if(!p_igetw(&(tempguy.weap_data.script),f))
14666 return qe_invalid;
14667
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if ( guyversion < 40 )
14668 102400 tempguy.weap_data.script = 0;
14669 //eweapon script InitD
14670
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
212480 if ( guyversion >= 41 )
14671 {
14672
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 26624 times.
110080 if(guyversion < 54)
14673
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 26624 times.
239616 for ( int32_t q = 0; q < 8; q++ )
14674
1/2
✓ Branch 0 taken 212992 times.
✗ Branch 1 not taken.
212992 if(!p_igetl(&(tempguy.weap_data.initd[q]),f))
14675 26624 return qe_invalid;
14676
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if ( guy_cversion < 4 )
14677 {
14678 if ( tempguy.type == eeKEESE )
14679 {
14680
14681 if ( !tempguy.attributes[0] )
14682 {
14683 tempguy.attributes[15] = 120;
14684 tempguy.attributes[16] = 16;
14685
14686 }
14687 }
14688 if ( tempguy.type == eePEAHAT )
14689 {
14690 tempguy.attributes[15] = 80;
14691 tempguy.attributes[16] = 16;
14692 }
14693
14694 if ( tempguy.type == eeGHINI )
14695 {
14696 tempguy.attributes[15] = 120;
14697 tempguy.attributes[16] = 10;
14698 }
14699
14700 }
14701 110080 }
14702
14703
14704
14705 //default weapon sprites (quest version < 2.54)
14706 //port over old defaults -Z
14707
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 32)
14708 {
14709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.wpnsprite <= 0 )
14710 {
14711
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14712 {
14713 case wNone:
14714 86878 tempguy.wpnsprite = 0; break;
14715
14716 case wSword:
14717 case wBeam:
14718 case wBrang:
14719 case wBomb:
14720 case wSBomb:
14721 case wLitBomb:
14722 case wLitSBomb:
14723 case wArrow:
14724 case wFire:
14725 case wWhistle:
14726 case wBait:
14727 case wWand:
14728 case wMagic:
14729 case wCatching:
14730 case wWind:
14731 case wRefMagic:
14732 case wRefFireball:
14733 case wRefRock:
14734 case wHammer:
14735 case wHookshot:
14736 case wHSHandle:
14737 case wHSChain:
14738 case wSSparkle:
14739 case wFSparkle:
14740 case wSmack:
14741 case wPhantom:
14742 case wCByrna:
14743 case wRefBeam:
14744 case wStomp:
14745 case lwMax:
14746 case wScript1:
14747 case wScript2:
14748 case wScript3:
14749 case wScript4:
14750 case wScript5:
14751 case wScript6:
14752 case wScript7:
14753 case wScript8:
14754 case wScript9:
14755 case wScript10:
14756 case wIce:
14757 //Cannot use any of these weapons yet.
14758 tempguy.wpnsprite = -1;
14759 break;
14760
14761 case wEnemyWeapons:
14762 2849 case ewFireball: tempguy.wpnsprite = 17; break;
14763
14764 801 case ewArrow: tempguy.wpnsprite = 19; break;
14765 691 case ewBrang: tempguy.wpnsprite = 4; break;
14766 1900 case ewSword: tempguy.wpnsprite = 20; break;
14767 1291 case ewRock: tempguy.wpnsprite = 18; break;
14768 2399 case ewMagic: tempguy.wpnsprite = 21; break;
14769 206 case ewBomb: tempguy.wpnsprite = 78; break;
14770 77 case ewSBomb: tempguy.wpnsprite = 79; break;
14771 448 case ewLitBomb: tempguy.wpnsprite = 76; break;
14772 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14773 906 case ewFireTrail: tempguy.wpnsprite = 80; break;
14774 1802 case ewFlame: tempguy.wpnsprite = 35; break;
14775 229 case ewWind: tempguy.wpnsprite = 36; break;
14776 325 case ewFlame2: tempguy.wpnsprite = 81; break;
14777 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14778 case ewIce: tempguy.wpnsprite = 83; break;
14779 1519 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14780
14781
14782 default: break; //No assign.
14783 }
14784 102400 }
14785 102400 }
14786
14787 //default weapon fire sound (quest version < 2.54)
14788 //port over old defaults and zero new data. -Z
14789
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 34)
14790 {
14791
2/2
✓ Branch 0 taken 3276800 times.
✓ Branch 1 taken 102400 times.
3379200 for ( int32_t q = 0; q < 32; q++ )
14792 {
14793 3276800 tempguy.movement[q] = 0;
14794 3276800 tempguy.new_weapon[q] = 0;
14795
14796 3276800 }
14797
14798 //NPC Script attributes.
14799 102400 tempguy.script = 0; //No scripted enemies existed. -Z
14800
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14801
14802
2/2
✓ Branch 0 taken 1740800 times.
✓ Branch 1 taken 102400 times.
1843200 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14803
14804 //old default sounds
14805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.firesfx <= 0 )
14806 {
14807
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14808 {
14809 case wNone:
14810 86878 tempguy.firesfx = 0; break;
14811
14812 case wSword:
14813 case wBeam:
14814 case wBrang:
14815 case wBomb:
14816 case wSBomb:
14817 case wLitBomb:
14818 case wLitSBomb:
14819 case wArrow:
14820 case wFire:
14821 case wWhistle:
14822 case wBait:
14823 case wWand:
14824 case wMagic:
14825 case wCatching:
14826 case wWind:
14827 case wRefMagic:
14828 case wRefFireball:
14829 case wRefRock:
14830 case wHammer:
14831 case wHookshot:
14832 case wHSHandle:
14833 case wHSChain:
14834 case wSSparkle:
14835 case wFSparkle:
14836 case wSmack:
14837 case wPhantom:
14838 case wCByrna:
14839 case wRefBeam:
14840 case wStomp:
14841 case lwMax:
14842 case wScript1:
14843 case wScript2:
14844 case wScript3:
14845 case wScript4:
14846 case wScript5:
14847 case wScript6:
14848 case wScript7:
14849 case wScript8:
14850 case wScript9:
14851 case wScript10:
14852 case wIce:
14853 //Cannot use any of these weapons yet.
14854 tempguy.firesfx = -1;
14855 break;
14856
14857 case wEnemyWeapons:
14858 2849 case ewFireball: tempguy.firesfx = 40; break;
14859
14860 801 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14861 691 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14862 1900 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14863 1291 case ewRock: tempguy.firesfx = 51; break;
14864 2399 case ewMagic: tempguy.firesfx = 32; break;
14865 206 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14866 77 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14867 448 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14868 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14869 906 case ewFireTrail: tempguy.firesfx = 13; break;
14870 1802 case ewFlame: tempguy.firesfx = 13; break;
14871 229 case ewWind: tempguy.firesfx = 32; break;
14872 325 case ewFlame2: tempguy.firesfx = 13; break;
14873 case ewFlame2Trail: tempguy.firesfx = 13; break;
14874 case ewIce: tempguy.firesfx = 44; break;
14875 1519 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14876
14877 //what about special attacks (e.g. summoning == 56)
14878 default: break; //No assign.
14879 }
14880 102400 }
14881 102400 }
14882
14883 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14884
4/6
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 110080 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 110080 times.
212480 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14885 {
14886
2/2
✓ Branch 0 taken 89799 times.
✓ Branch 1 taken 12601 times.
102400 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14887 102400 }
14888 //Keese and bat halt rates.
14889
3/4
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 110080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102400 times.
212480 if ( guyversion < 42 && guy_cversion < 4 )
14890 {
14891
14892
2/2
✓ Branch 0 taken 101101 times.
✓ Branch 1 taken 1299 times.
102400 if ( tempguy.type == eeKEESE )
14893 {
14894
14895
2/2
✓ Branch 0 taken 935 times.
✓ Branch 1 taken 364 times.
1299 if ( !tempguy.attributes[0] )
14896 {
14897 935 tempguy.attributes[15] = 120;
14898 935 tempguy.attributes[16] = 16;
14899
14900 935 }
14901 1299 }
14902
2/2
✓ Branch 0 taken 101935 times.
✓ Branch 1 taken 465 times.
102400 if ( tempguy.type == eePEAHAT )
14903 {
14904 465 tempguy.attributes[15] = 80;
14905 465 tempguy.attributes[16] = 16;
14906 465 }
14907
2/2
✓ Branch 0 taken 102200 times.
✓ Branch 1 taken 200 times.
102400 if ( tempguy.type == eeGHINI )
14908 {
14909 200 tempguy.attributes[15] = 120;
14910 200 tempguy.attributes[16] = 10;
14911 200 }
14912
14913
14914 102400 }
14915
14916
14917 //miscellaneous other corrections
14918 //fix the mirror wizzrobe -DD
14919
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 7)
14920 {
14921 if(i == eMWIZ)
14922 {
14923 tempguy.attributes[1] = 0;
14924 tempguy.attributes[3] = 1;
14925 }
14926 }
14927
14928
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 8)
14929 {
14930 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14931 {
14932 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14933 tempguy.attributes[4] = 4; //neck length in segments
14934 tempguy.attributes[5] = 8; //neck offset from first body tile
14935 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14936 tempguy.attributes[7] = 168; //head offset from first body tile
14937 tempguy.attributes[8] = 228; //flying head offset from first body tile
14938
14939 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14940 {
14941 tempguy.attributes[5] += 10; //neck offset from first body tile
14942 tempguy.attributes[7] -= 12; //head offset from first body tile
14943 }
14944 }
14945 }
14946
14947
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14948 {
14949 if(get_bit(deprecated_rules,46) && tempguy.type==eeDONGO && tempguy.attributes[0]==0)
14950 tempguy.bosspal = spDIG;
14951 }
14952
14953
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 11) // December 2007 - Spinning Tile fix
14954 {
14955 if(tempguy.type==eeSPINTILE)
14956 {
14957 tempguy.flags |= guy_superman;
14958 tempguy.item_set = 0; // Don't drop items
14959 tempguy.step = 300;
14960 }
14961 }
14962
14963
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14964 {
14965 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14966 {
14967 if(tempguy.type==eeROPE)
14968 {
14969 tempguy.flags &= ~guy_flashing;
14970 }
14971 }
14972
14973 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14974 {
14975 if(tempguy.type==eeBUBBLE)
14976 {
14977 tempguy.flags &= ~guy_flashing;
14978 }
14979 }
14980
14981 if((tempguy.type==eeGHINI)&&(tempguy.attributes[0]))
14982 {
14983 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14984 {
14985 tempguy.flags |= guy_blinking;
14986 }
14987
14988 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14989 {
14990 tempguy.flags |= guy_transparent;
14991 }
14992 }
14993 }
14994
14995
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14996 {
14997 if(i==gFIRE)
14998 {
14999 tempguy.e_anim = aFLIP;
15000 tempguy.e_frate = 24;
15001 }
15002
15003 if(i==gFAIRY)
15004 {
15005 tempguy.e_anim = a2FRM;
15006 tempguy.e_frate = 16;
15007 }
15008 }
15009
15010
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15011 {
15012 if(i==0) Z_message("Updating guys to version 16...\n");
15013
15014 update_guy_1(&tempguy);
15015
15016 if(i==eMPOLSV)
15017 {
15018 tempguy.defense[edefARROW] = edCHINK;
15019 tempguy.defense[edefMAGIC] = ed1HKO;
15020 tempguy.defense[edefREFMAGIC] = ed1HKO;
15021 }
15022 }
15023
15024
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 17) // December 2009
15025 {
15026 if(tempguy.type==eePROJECTILE)
15027 {
15028 tempguy.attributes[0] = 0;
15029 }
15030 }
15031
15032
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 18) // January 2010
15033 {
15034 bool boss = (tempguy.type == eeAQUA || tempguy.type==eeDONGO || tempguy.type == eeMANHAN || tempguy.type == eeGHOMA || tempguy.type==eeDIG
15035 || tempguy.type == eeGLEEOK || tempguy.type==eePATRA || tempguy.type == eeGANON || tempguy.type==eeMOLD);
15036
15037 tempguy.hitsfx = (boss && tempguy.type != eeMOLD && tempguy.type != eeDONGO && tempguy.type != eeDIG) ? WAV_GASP : 0;
15038 tempguy.deadsfx = (boss && (tempguy.type != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
15039
15040 if(tempguy.type == eeAQUA)
15041 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15042 else if(tempguy.type == eeMANHAN)
15043 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15044 else if(tempguy.type==eePATRA)
15045 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15046 else if(tempguy.type==eeGHOMA)
15047 {
15048 for(int32_t j=0; j<edefLAST; j++)
15049 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15050
15051 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
15052
15053 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15054
15055 tempguy.attributes[0]--;
15056 }
15057 else if(tempguy.type == eeGLEEOK)
15058 {
15059 for(int32_t j=0; j<edefLAST; j++)
15060 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15061
15062 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15063 }
15064 else if(tempguy.type == eeARMOS)
15065 {
15066 tempguy.type=eeWALK;
15067 tempguy.hrate = 0;
15068 tempguy.attributes[9] = tempguy.attributes[0];
15069 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
15070 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
15071 tempguy.attributes[8] = e9tARMOS;
15072 }
15073 else if(tempguy.type == eeGHINI && !tempguy.attributes[0])
15074 {
15075 tempguy.type=eeWALK;
15076 tempguy.hrate = 0;
15077 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
15078 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
15079 }
15080
15081 // Spawn animation flags
15082 if(tempguy.type == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
15083 tempguy.flags |= guy_fade_flicker;
15084 else
15085 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
15086 }
15087
15088
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 20) // April 2010
15089 {
15090 if(tempguy.type == eeTRAP)
15091 {
15092 tempguy.attributes[1] = tempguy.attributes[9];
15093
15094 if(tempguy.attributes[9]>=1)
15095 {
15096 tempguy.attributes[0]++;
15097 }
15098
15099 tempguy.attributes[9] = 0;
15100 }
15101
15102 // Bomb Blast fix
15103 if(tempguy.weapon==ewBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
15104 tempguy.weapon = ewLitBomb;
15105 else if(tempguy.weapon==ewSBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
15106 tempguy.weapon = ewLitSBomb;
15107 }
15108
15109
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 21) // September 2011
15110 {
15111 if(tempguy.type == eeKEESE || tempguy.type == eeKEESETRIB)
15112 {
15113 if(tempguy.type == eeKEESETRIB)
15114 {
15115 tempguy.type = eeKEESE;
15116 tempguy.attributes[1] = e2tKEESETRIB;
15117 tempguy.attributes[0] = 0;
15118 }
15119
15120 tempguy.rate = 2;
15121 tempguy.hrate = 8;
15122 tempguy.homing = 0;
15123 tempguy.step= (tempguy.type == eeKEESE && tempguy.attributes[0] ? 100:62);
15124 }
15125 else if(tempguy.type == eePEAHAT || tempguy.type==eePATRA)
15126 {
15127 if(tempguy.type == eePEAHAT)
15128 {
15129 tempguy.rate = 4;
15130 tempguy.step = 62;
15131 }
15132 else
15133 tempguy.step = 25;
15134
15135 tempguy.hrate = 8;
15136 tempguy.homing = 0;
15137 }
15138 else if(tempguy.type == eeDIG || tempguy.type == eeMANHAN)
15139 {
15140 if(tempguy.type == eeMANHAN)
15141 tempguy.step=50;
15142
15143 tempguy.hrate = 16;
15144 tempguy.homing = 0;
15145 }
15146 else if(tempguy.type == eeGLEEOK)
15147 {
15148 tempguy.rate = 2;
15149 tempguy.homing = 0;
15150 tempguy.hrate = 9;
15151 tempguy.step=89;
15152 }
15153 else if(tempguy.type == eeGHINI)
15154 {
15155 tempguy.rate = 4;
15156 tempguy.hrate = 12;
15157 tempguy.step=62;
15158 tempguy.homing = 0;
15159 }
15160
15161 // Bigdig random rate fix
15162 if(tempguy.type==eeDIG && tempguy.attributes[9]==1)
15163 {
15164 tempguy.rate = 2;
15165 }
15166 }
15167
15168
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(guyversion < 24) // November 2012
15169 {
15170 if(tempguy.type==eeLANM)
15171 tempguy.attributes[2] = 1;
15172 else if(tempguy.type==eeMOLD)
15173 tempguy.attributes[1] = 0;
15174 }
15175
15176
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15177 {
15178
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 101000 times.
102400 if(tempguy.type!=eeDIG)
15179 {
15180 101000 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15181 101000 }
15182
15183 102400 }
15184 // does not seem to solve the issue!
15185
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if ( Header->zelda_version <= 0x210 )
15186 {
15187 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15188 if ( tempguy.type == eeDONGO )
15189 {
15190 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15191 }
15192 }
15193
15194
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion >= 42)
15195 {
15196
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 2560 times.
110080 if(guyversion >= 47)
15197 {
15198
1/2
✓ Branch 0 taken 107520 times.
✗ Branch 1 not taken.
107520 if(!p_igetl(&(tempguy.moveflags),f))
15199 {
15200 return qe_invalid;
15201 }
15202 107520 }
15203 else
15204 {
15205 byte fl;
15206
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
15207 {
15208 return qe_invalid;
15209 }
15210 2560 tempguy.moveflags = (move_flags)fl;
15211 }
15212 110080 }
15213 else
15214 {
15215
7/8
✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 80670 times.
✓ Branch 2 taken 2717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 958 times.
✓ Branch 5 taken 642 times.
✓ Branch 6 taken 498 times.
✓ Branch 7 taken 13859 times.
102400 switch(tempguy.type)
15216 {
15217 //No gravity; floats over pits
15218 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15219 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15220 //Special (bosses, etc)
15221 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15222 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15223 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15224 80670 tempguy.moveflags = move_can_pitwalk;
15225 80670 break;
15226 //No gravity, but falls in pits
15227 case eeLEV:
15228 958 tempguy.moveflags = move_can_pitfall;
15229 958 break;
15230 //Bosses that respect pits
15231 case eeDONGO:
15232 642 tempguy.moveflags = move_obeys_grav;
15233 642 break;
15234 case eeLANM:
15235 498 tempguy.moveflags = move_none;
15236 498 break;
15237 //Gravity, floats over pits
15238 case eeWIZZ: case eeWALLM: case eeGHINI:
15239 2717 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15240 2717 break;
15241 //Gravity and falls in pits
15242 case eeWALK:
15243
4/4
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 695 times.
✓ Branch 2 taken 529 times.
✓ Branch 3 taken 12635 times.
13859 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15244 1224 break;
15245 [[fallthrough]];
15246 case eeOTHER:
15247 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15248 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15249 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15250 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15251 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15252 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15253 15691 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15254 15691 }
15255 }
15256
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 43)
15257 {
15258
2/2
✓ Branch 0 taken 83387 times.
✓ Branch 1 taken 19013 times.
102400 switch(tempguy.type)
15259 {
15260 //No gravity; floats over pits
15261 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15262 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15263 //Special (bosses, etc)
15264 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15265 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15266 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15267 case eeWIZZ: case eeWALLM: case eeGHINI:
15268 //Gravity, floats over pits
15269 83387 tempguy.moveflags |= move_can_waterwalk;
15270 83387 tempguy.moveflags |= move_can_pitwalk;
15271 83387 break;
15272 }
15273 102400 }
15274
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if (guyversion < 44)
15275 {
15276
2/2
✓ Branch 0 taken 101487 times.
✓ Branch 1 taken 913 times.
102400 if ( tempguy.type == eeGHOMA )
15277 {
15278 913 tempguy.flags |= guy_fade_instant;
15279 913 }
15280 102400 }
15281
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if (guyversion > 44)
15282 {
15283
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_getc(&(tempguy.spr_shadow),f))
15284 {
15285 return qe_invalid;
15286 }
15287
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_getc(&(tempguy.spr_death),f))
15288 {
15289 return qe_invalid;
15290 }
15291
1/2
✓ Branch 0 taken 110080 times.
✗ Branch 1 not taken.
110080 if(!p_getc(&(tempguy.spr_spawn),f))
15292 {
15293 return qe_invalid;
15294 }
15295 110080 }
15296 else
15297 {
15298
2/2
✓ Branch 0 taken 102003 times.
✓ Branch 1 taken 397 times.
102400 tempguy.spr_shadow = (tempguy.type==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15299 102400 tempguy.spr_death = iwDeath;
15300 102400 tempguy.spr_spawn = iwSpawn;
15301 }
15302
15303
2/2
✓ Branch 0 taken 110080 times.
✓ Branch 1 taken 102400 times.
212480 if(guyversion < 46)
15304 {
15305
4/4
✓ Branch 0 taken 13859 times.
✓ Branch 1 taken 88541 times.
✓ Branch 2 taken 13164 times.
✓ Branch 3 taken 695 times.
102400 if(tempguy.type == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15306 {
15307 695 tempguy.moveflags |= move_can_waterwalk;
15308 695 }
15309 102400 }
15310
15311
2/2
✓ Branch 0 taken 107520 times.
✓ Branch 1 taken 104960 times.
212480 if (guyversion < 47)
15312 {
15313
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 103530 times.
✓ Branch 2 taken 856 times.
✓ Branch 3 taken 574 times.
104960 if (tempguy.type == eeDIG && tempguy.attributes[9]!=1)
15314 {
15315 574 tempguy.flags |= guy_ignore_kill_all;
15316 574 }
15317 104960 }
15318
15319
2/2
✓ Branch 0 taken 86528 times.
✓ Branch 1 taken 125952 times.
212480 if (guyversion < 49)
15320 {
15321
8/8
✓ Branch 0 taken 16458 times.
✓ Branch 1 taken 109494 times.
✓ Branch 2 taken 15984 times.
✓ Branch 3 taken 474 times.
✓ Branch 4 taken 15499 times.
✓ Branch 5 taken 485 times.
✓ Branch 6 taken 530 times.
✓ Branch 7 taken 14969 times.
125952 if (tempguy.type == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15322 {
15323
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 713 times.
✓ Branch 2 taken 715 times.
✓ Branch 3 taken 61 times.
1489 switch (tempguy.attributes[7]) {
15324 case 0: //Sword
15325 713 tempguy.attributes[7] = e8tSWORD;
15326 713 break;
15327 case 1: //Item
15328 715 tempguy.attributes[7] = e8tITEM;
15329 715 break;
15330 case 2: //Both
15331 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15332 61 break;
15333 default: //this can actually happen since Misc8 can be set to any number.
15334 tempguy.attributes[7] = 0;
15335 break;
15336 }
15337 1489 }
15338 125952 }
15339
15340 //these could possible be combined but rather be safe...
15341
2/2
✓ Branch 0 taken 86528 times.
✓ Branch 1 taken 125952 times.
212480 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15342 {
15343 125952 guy_update_firesfx(tempguy);
15344 125952 }
15345
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 86528 times.
212480 if (guyversion < 52)
15346 {
15347 125952 guy_update_weaponflags(tempguy);
15348 125952 }
15349
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 3072 times.
86528 else if(guyversion < 54)
15350 {
15351
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_getc(&(tempguy.weap_data.unblockable), f))
15352 return qe_invalid;
15353
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.moveflags), f))
15354 return qe_invalid;
15355
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.override_flags), f))
15356 return qe_invalid;
15357
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.tilew), f))
15358 return qe_invalid;
15359
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.tileh), f))
15360 return qe_invalid;
15361
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hxsz), f))
15362 return qe_invalid;
15363
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hysz), f))
15364 return qe_invalid;
15365
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hzsz), f))
15366 return qe_invalid;
15367
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hxofs), f))
15368 return qe_invalid;
15369
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hyofs), f))
15370 return qe_invalid;
15371
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.xofs), f))
15372 return qe_invalid;
15373
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.yofs), f))
15374 return qe_invalid;
15375 int32_t temp_step;
15376
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&temp_step, f))
15377 return qe_invalid;
15378 3072 tempguy.weap_data.step = zslongToFix(temp_step*100);
15379
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 3072 times.
18432 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15380 {
15381
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (!p_igetw(&(tempguy.weap_data.burnsprs[q]), f))
15382 return qe_invalid;
15383
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (!p_igetw(&(tempguy.weap_data.light_rads[q]), f))
15384 return qe_invalid;
15385 15360 }
15386 3072 }
15387
2/2
✓ Branch 0 taken 125952 times.
✓ Branch 1 taken 86528 times.
212480 if (guyversion < 53)
15388 {
15389 125952 guy_update_weaponspecialsfx(tempguy);
15390 125952 }
15391 else
15392 {
15393
1/2
✓ Branch 0 taken 86528 times.
✗ Branch 1 not taken.
86528 if (!p_getc(&(tempguy.specialsfx), f))
15394 return qe_invalid;
15395 }
15396
15397
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 129024 times.
212480 if(guyversion >= 54)
15398 {
15399
1/2
✓ Branch 0 taken 83456 times.
✗ Branch 1 not taken.
83456 if(auto ret = read_weap_data(tempguy.weap_data, f))
15400 return ret;
15401 83456 }
15402 else
15403 {
15404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129024 times.
129024 SETFLAG(tempguy.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempguy.flags & guy_burning_sprites);
15405 129024 tempguy.weap_data.flags |= wdata_set_step;
15406
2/2
✓ Branch 0 taken 127437 times.
✓ Branch 1 taken 1587 times.
129024 if(tempguy.weapon == ewRock)
15407 1587 tempguy.weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
15408 }
15409
15410
1/2
✓ Branch 0 taken 212480 times.
✗ Branch 1 not taken.
212480 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15411 {
15412 tempguy.script = 0;
15413 for(int q = 0; q < 8; ++q)
15414 tempguy.initD[q] = 0;
15415 }
15416 212480 guysbuf[i] = tempguy;
15417 212480 }
15418 415 }
15419
15420 415 return 0;
15421 497 }
15422
15423 void update_guy_1(guydata *tempguy) // November 2009
15424 {
15425 bool doesntcount = false;
15426 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15427
15428 switch(tempguy->type)
15429 {
15430 case 1: //eeWALK
15431 switch(tempguy->attributes[9])
15432 {
15433 case 0: //Stalfos
15434 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15435 tempguy->attributes[0]=4;
15436
15437 break;
15438
15439 case 1: //Darknut
15440 goto darknuts;
15441 break;
15442 }
15443
15444 tempguy->attributes[9] = 0;
15445 break;
15446
15447 case 2: //eeSHOOT
15448 tempguy->type = eeWALK;
15449
15450 switch(tempguy->attributes[9])
15451 {
15452 case 0: //Octorok
15453 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15454 {
15455 tempguy->attributes[0]=e1tFIREOCTO;
15456 tempguy->attributes[1]=e2tFIREOCTO;
15457 }
15458 else tempguy->attributes[0] = 0;
15459
15460 tempguy->attributes[5]=tempguy->attributes[3];
15461 tempguy->attributes[3]=tempguy->attributes[2];
15462 tempguy->attributes[2]=0;
15463 break;
15464
15465 case 1: // Moblin
15466 tempguy->attributes[0] = 0;
15467 break;
15468
15469 case 2: //Lynel
15470 tempguy->attributes[5]=tempguy->attributes[0]+1;
15471 tempguy->attributes[0]=0;
15472 break;
15473
15474 case 3: //Stalfos 2
15475 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15476 tempguy->attributes[0]=e1t4SHOTS;
15477 else tempguy->attributes[0] = 0;
15478
15479 break;
15480
15481 case 4: //Darknut 5
15482 darknuts:
15483 tempguy->defense[edefFIRE] = edIGNORE;
15484 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15485 tempguy->defense[edefHOOKSHOT] = 0;
15486 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15487 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15488
15489 if(tempguy->attributes[0]==1)
15490 tempguy->attributes[0]=2;
15491 else if(tempguy->attributes[0]==2)
15492 {
15493 tempguy->attributes[3]=tempguy->attributes[2];
15494 tempguy->attributes[2]=tempguy->attributes[1];
15495 tempguy->attributes[1]=e2tSPLIT;
15496 tempguy->attributes[0] = 0;
15497 }
15498 else tempguy->attributes[0] = 0;
15499
15500 tempguy->flags |= guy_shield_front;
15501
15502 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15503 tempguy->flags &= ~guy_bkshield;
15504 else
15505 tempguy->flags |= guy_bkshield;
15506
15507 break;
15508 }
15509
15510 tempguy->attributes[9] = 0;
15511 break;
15512
15513 /*
15514 case 9: //eeARMOS
15515 tempguy->family = eeWALK;
15516 break;
15517 */
15518 case 11: //eeGEL
15519 case 33: //eeGELTRIB
15520 if(tempguy->type==33)
15521 {
15522 tempguy->attributes[3] = 1;
15523
15524 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15525 tempguy->attributes[2] = tempguy->attributes[1];
15526
15527 tempguy->attributes[1] = e2tTRIBBLE;
15528 }
15529 else
15530 {
15531 tempguy->attributes[3] = 0;
15532 tempguy->attributes[2] = 0;
15533 tempguy->attributes[1] = 0;
15534 }
15535
15536 tempguy->type = eeWALK;
15537
15538 if(tempguy->attributes[0])
15539 {
15540 tempguy->attributes[0]=1;
15541 tempguy->weapon = ewFireTrail;
15542 }
15543
15544 break;
15545
15546 case 34: //eeZOLTRIB
15547 case 12: //eeZOL
15548 tempguy->attributes[3]=tempguy->attributes[2];
15549 tempguy->attributes[2]=tempguy->attributes[1];
15550 tempguy->type = eeWALK;
15551 tempguy->attributes[1]=e2tSPLITHIT;
15552
15553 if(tempguy->attributes[0])
15554 {
15555 tempguy->attributes[0]=1;
15556 tempguy->weapon = ewFireTrail;
15557 }
15558
15559 break;
15560
15561 case 13: //eeROPE
15562 tempguy->type = eeWALK;
15563 tempguy->attributes[8] = e9tROPE;
15564
15565 if(tempguy->attributes[0])
15566 {
15567 tempguy->attributes[3] = tempguy->attributes[2];
15568 tempguy->attributes[2] = tempguy->attributes[1];
15569 tempguy->attributes[1] = e2tBOMBCHU;
15570 }
15571
15572 tempguy->attributes[0] = 0;
15573 break;
15574
15575 case 14: //eeGORIYA
15576 tempguy->type = eeWALK;
15577
15578 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15579
15580 break;
15581
15582 case 17: //eeBUBBLE
15583 tempguy->type = eeWALK;
15584 tempguy->attributes[7] = tempguy->attributes[1];
15585 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15586 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15587
15588 //fallthrogh
15589 case eeTRAP:
15590 case eeROCK:
15591 doesntcount = true;
15592 break;
15593
15594 case 35: //eeVIRETRIB
15595 case 18: //eeVIRE
15596 tempguy->type = eeWALK;
15597 tempguy->attributes[3]=tempguy->attributes[2];
15598 tempguy->attributes[2]=tempguy->attributes[1];
15599 tempguy->attributes[1]=e2tSPLITHIT;
15600 tempguy->attributes[8]=e9tVIRE;
15601 break;
15602
15603 case 19: //eeLIKE
15604 tempguy->type = eeWALK;
15605 tempguy->attributes[6] = e7tEATITEMS;
15606 tempguy->attributes[7]=95;
15607 break;
15608
15609 case 20: //eePOLSV
15610 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15611 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15612 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15613 tempguy->defense[edefARROW] = ed1HKO;
15614 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15615 tempguy->type = eeWALK;
15616 tempguy->attributes[8] = e9tPOLSVOICE;
15617 tempguy->rate = 4;
15618 tempguy->homing = 32;
15619 tempguy->hrate = 10;
15620 tempguy->grumble = 0;
15621 break;
15622
15623 case eeWIZZ:
15624 if(tempguy->attributes[3])
15625 {
15626 for(int32_t i=0; i < edefLAST; i++)
15627 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15628 }
15629 else
15630 {
15631 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15632 tempguy->defense[edefMAGIC] = edCHINK;
15633 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15634 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15635 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15636 }
15637
15638 break;
15639
15640 case eePEAHAT:
15641 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15642
15643 if(!(tempguy->flags & guy_bhit))
15644 tempguy->defense[edefBRANG] = edSTUNONLY;
15645
15646 break;
15647
15648 case eeLEV:
15649 tempguy->defense[edefSTOMP] = edCHINK;
15650 break;
15651 }
15652
15653 // Old flags
15654 if(tempguy->flags & guy_superman)
15655 {
15656 for(int32_t i = 0; i < edefLAST; i++)
15657 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15658 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15659 && tempguy->type != eeROCK && tempguy->type != eeTRAP
15660 && tempguy->type != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15661 }
15662
15663 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15664
15665 if(doesntcount)
15666 tempguy->flags |= (guy_doesnt_count);
15667 }
15668
15669 1178856 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind, bool keep_music)
15670 {
15671 1178856 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
15672
15673 byte tempbyte, padding;
15674 word wpadding;
15675 int32_t extras, secretcombos;
15676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->valid),f))
15677 {
15678 return qe_invalid;
15679 }
15680
15681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->guy),f))
15682 return qe_invalid;
15683 1178856 temp_mapscr->guytile = -1; //signal to use default guy values
15684
2/2
✓ Branch 0 taken 1178256 times.
✓ Branch 1 taken 600 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15685
4/4
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 1178256 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 538 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15686
15687
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15688 {
15689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15690 {
15691 return qe_invalid;
15692 }
15693
15694 22176 temp_mapscr->str=tempbyte;
15695 22176 }
15696 else
15697 {
15698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->str),f))
15699 {
15700 return qe_invalid;
15701 }
15702 }
15703
15704
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->room),f))
15705 {
15706 return qe_invalid;
15707 }
15708
15709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->item),f))
15710 {
15711 return qe_invalid;
15712 }
15713
15714
3/6
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 650352 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15715 {
15716 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15717 528504 }
15718 else
15719 {
15720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->hasitem),f))
15721 return qe_invalid;
15722 }
15723
15724
3/4
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1181576 if((Header->zelda_version < 0x192)||
15725
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15726 {
15727
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15728 {
15729 return qe_invalid;
15730 }
15731 22176 }
15732
15733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15734 {
15735 return qe_invalid;
15736 }
15737
15738
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15739 {
15740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15741 {
15742 return qe_invalid;
15743 }
15744 24896 }
15745
15746
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15747 {
15748
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15749 {
15750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15751 {
15752 return qe_invalid;
15753 }
15754 1951056 }
15755 650352 }
15756 else
15757 {
15758 528504 temp_mapscr->tilewarptype[1]=0;
15759 528504 temp_mapscr->tilewarptype[2]=0;
15760 528504 temp_mapscr->tilewarptype[3]=0;
15761 }
15762
15763
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15764 {
15765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15766 {
15767 return qe_invalid;
15768 }
15769 1156680 }
15770
15771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15772 {
15773 return qe_invalid;
15774 }
15775
15776 1178856 temp_mapscr->warpreturnx[1]=0;
15777 1178856 temp_mapscr->warpreturnx[2]=0;
15778 1178856 temp_mapscr->warpreturnx[3]=0;
15779
15780
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15781 {
15782
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15783 {
15784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15785 {
15786 return qe_invalid;
15787 }
15788 1951056 }
15789 650352 }
15790
15791
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15792 {
15793 return qe_invalid;
15794 }
15795
15796 1178856 temp_mapscr->warpreturny[1]=0;
15797 1178856 temp_mapscr->warpreturny[2]=0;
15798 1178856 temp_mapscr->warpreturny[3]=0;
15799
15800
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15801 {
15802
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15803 {
15804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15805 {
15806 return qe_invalid;
15807 }
15808 1951056 }
15809
15810
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(version>=18)
15811 {
15812
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15813 {
15814 return qe_invalid;
15815 }
15816 650352 }
15817 else
15818 {
15819 byte temp;
15820
15821 if(!p_getc(&temp,f))
15822 {
15823 return qe_invalid;
15824 }
15825
15826 temp_mapscr->warpreturnc=temp<<8|temp;
15827 }
15828 650352 }
15829
15830
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->stairx),f))
15831
15832 {
15833 return qe_invalid;
15834 }
15835
15836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->stairy),f))
15837 {
15838 return qe_invalid;
15839 }
15840
15841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemx),f))
15842 {
15843 return qe_invalid;
15844 }
15845
15846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemy),f))
15847 {
15848 return qe_invalid;
15849 }
15850
15851
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version > 15) // February 2009
15852 {
15853
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->color),f))
15854 {
15855 return qe_invalid;
15856 }
15857 650352 }
15858 else
15859 {
15860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15861 {
15862 return qe_invalid;
15863 }
15864
15865 528504 temp_mapscr->color = (word) tempbyte;
15866 }
15867
15868
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags11),f))
15869 {
15870 return qe_invalid;
15871 }
15872
15873
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
15874 {
15875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->door[k]),f))
15876 {
15877 return qe_invalid;
15878
15879 }
15880 4715424 }
15881
15882
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
15883 {
15884
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15885 {
15886 return qe_invalid;
15887 }
15888
15889 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15890
15891
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15892 {
15893 for(int32_t i=1; i<4; i++)
15894 {
15895 if(!p_getc(&(tempbyte),f))
15896 {
15897 return qe_invalid;
15898 }
15899
15900 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15901 }
15902 }
15903 else
15904 {
15905 528504 temp_mapscr->tilewarpdmap[1]=0;
15906 528504 temp_mapscr->tilewarpdmap[2]=0;
15907 528504 temp_mapscr->tilewarpdmap[3]=0;
15908 }
15909 528504 }
15910 else
15911 {
15912
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
15913 {
15914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15915 {
15916 return qe_invalid;
15917 }
15918 2601408 }
15919 }
15920
15921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15922 {
15923 return qe_invalid;
15924 }
15925
15926
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15927 {
15928
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15929 {
15930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15931 {
15932 return qe_invalid;
15933 }
15934 1951056 }
15935 650352 }
15936 else
15937 {
15938 528504 temp_mapscr->tilewarpscr[1]=0;
15939 528504 temp_mapscr->tilewarpscr[2]=0;
15940 528504 temp_mapscr->tilewarpscr[3]=0;
15941 }
15942
15943
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
15944 {
15945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15946 {
15947 return qe_invalid;
15948 }
15949 650352 }
15950 else
15951 {
15952 528504 temp_mapscr->tilewarpoverlayflags=0;
15953 }
15954
15955
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->exitdir),f))
15956 {
15957 return qe_invalid;
15958 }
15959
15960
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15961 {
15962
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15963 {
15964 return qe_invalid;
15965 }
15966
15967 24896 }
15968
15969
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15970 {
15971 if(!p_getc(&padding,f))
15972 {
15973 return qe_invalid;
15974 }
15975 }
15976
15977
2/2
✓ Branch 0 taken 11788560 times.
✓ Branch 1 taken 1178856 times.
12967416 for(int32_t k=0; k<10; k++)
15978 {
15979
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15980 {
15981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15982 {
15983 return qe_invalid;
15984 }
15985
15986 221760 temp_mapscr->enemy[k]=tempbyte;
15987
15988 // 76 is the highest enemy id possible to set in 1.90. Anything higher must have come
15989 // from corrupting when 1.90 saved the quest.
15990 // https://discord.com/channels/876899628556091432/1287580827164737658
15991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if (Header->zelda_version <= 0x190)
15992 {
15993
1/2
✓ Branch 0 taken 221760 times.
✗ Branch 1 not taken.
221760 if (temp_mapscr->enemy[k] > 76)
15994 {
15995 temp_mapscr->enemy[k] = 0;
15996 }
15997 221760 }
15998 221760 }
15999 else
16000 {
16001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11566800 times.
11566800 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16002 {
16003 return qe_invalid;
16004 }
16005 }
16006
16007
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
16008 {
16009 //using enumerations here is dangerous
16010 //very easy to break old quests -DD
16011
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
16012 {
16013 1342 temp_mapscr->enemy[k]+=5;
16014 1342 }
16015
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
16016 {
16017 94 temp_mapscr->enemy[k]+=1;
16018 94 }
16019 221760 }
16020
16021
2/2
✓ Branch 0 taken 6503520 times.
✓ Branch 1 taken 5285040 times.
11788560 if(version < 9)
16022 {
16023
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
16024 {
16025 275905 temp_mapscr->enemy[k]+=10;
16026 275905 }
16027 5285040 }
16028 //don't read in any invalid data
16029
2/2
✓ Branch 0 taken 11788110 times.
✓ Branch 1 taken 450 times.
11788560 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
16030 {
16031 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
16032 450 temp_mapscr->enemy[k] = 0;
16033 450 }
16034 11788560 }
16035
16036
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->pattern),f))
16037 {
16038 return qe_invalid;
16039 }
16040
16041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
16042 {
16043 return qe_invalid;
16044 }
16045
16046
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16047 {
16048
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
16049 {
16050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16051 {
16052 return qe_invalid;
16053 }
16054 1951056 }
16055 650352 }
16056 else
16057 {
16058 528504 temp_mapscr->sidewarptype[1]=0;
16059 528504 temp_mapscr->sidewarptype[2]=0;
16060 528504 temp_mapscr->sidewarptype[3]=0;
16061 }
16062
16063
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
16064 {
16065
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16066 {
16067 return qe_invalid;
16068 }
16069 650352 }
16070 else
16071 {
16072 528504 temp_mapscr->sidewarpoverlayflags=0;
16073 }
16074
16075
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16076 {
16077 return qe_invalid;
16078 }
16079
16080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16081 {
16082 return qe_invalid;
16083 }
16084
16085
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
16086 {
16087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->path[k]),f))
16088 {
16089 return qe_invalid;
16090 }
16091 4715424 }
16092
16093
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
16094 {
16095 return qe_invalid;
16096 }
16097
16098
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16099 {
16100
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 1951056 times.
2601408 for(int32_t i=1; i<4; i++)
16101 {
16102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16103 {
16104 return qe_invalid;
16105 }
16106 1951056 }
16107 650352 }
16108 else
16109 {
16110 528504 temp_mapscr->sidewarpscr[1]=0;
16111 528504 temp_mapscr->sidewarpscr[2]=0;
16112 528504 temp_mapscr->sidewarpscr[3]=0;
16113 }
16114
16115
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
16116 {
16117
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
16118 {
16119 return qe_invalid;
16120 }
16121
16122 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16123
16124
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16125 {
16126 for(int32_t i=1; i<4; i++)
16127 {
16128 if(!p_getc(&(tempbyte),f))
16129 {
16130 return qe_invalid;
16131 }
16132
16133 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16134 }
16135 }
16136 else
16137 {
16138 528504 temp_mapscr->sidewarpdmap[1]=0;
16139 528504 temp_mapscr->sidewarpdmap[2]=0;
16140 528504 temp_mapscr->sidewarpdmap[3]=0;
16141 }
16142 528504 }
16143 else
16144 {
16145
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
16146 {
16147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16148 {
16149 return qe_invalid;
16150 }
16151 2601408 }
16152 }
16153
16154
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16155 {
16156
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16157 {
16158 return qe_invalid;
16159 }
16160 650352 }
16161 528504 else temp_mapscr->sidewarpindex = 0;
16162
16163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_igetw(&(temp_mapscr->undercombo),f))
16164 {
16165 return qe_invalid;
16166 }
16167
16168 1178856 byte old_combo_page = 0;
16169
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
16170 {
16171
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_page, f))
16172 {
16173 return qe_invalid;
16174 }
16175
16176
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 24624 times.
24896 if (!should_skip)
16177 {
16178 24624 old_combo_pages[scrind] = old_combo_page;
16179 24624 }
16180 24896 }
16181
16182
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16183 {
16184 return qe_invalid;
16185 }
16186
16187
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_igetw(&(temp_mapscr->catchall),f))
16188 {
16189 return qe_invalid;
16190 }
16191
16192
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags),f))
16193 {
16194 return qe_invalid;
16195 }
16196
16197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags2),f))
16198 {
16199 return qe_invalid;
16200 }
16201
16202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags3),f))
16203 {
16204 return qe_invalid;
16205 }
16206
16207
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16208 //if (version>2)
16209 {
16210
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags4),f))
16211 {
16212 return qe_invalid;
16213 }
16214 650352 }
16215
16216
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16217 {
16218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags5),f))
16219 {
16220 return qe_invalid;
16221 }
16222
16223
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16224 return qe_invalid;
16225 650352 temp_mapscr->noreset = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED;
16226
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16227 return qe_invalid;
16228 1300704 temp_mapscr->nocarry = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED |
16229 650352 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16230
16231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(temp_mapscr->flags5&32)
16232 {
16233 temp_mapscr->flags5 &= ~32;
16234 temp_mapscr->noreset |= 48;
16235 }
16236
16237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(version<8)
16238 {
16239 if(temp_mapscr->noreset&1)
16240 {
16241 temp_mapscr->noreset|=8192;
16242 }
16243
16244 if(temp_mapscr->nocarry&1)
16245 {
16246 temp_mapscr->nocarry|=8192;
16247 temp_mapscr->nocarry&=~1;
16248 }
16249 }
16250 650352 }
16251 else
16252 {
16253 528504 temp_mapscr->flags5 = 0;
16254 528504 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
16255 528504 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
16256 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16257 }
16258
16259
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16260 {
16261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags6),f))
16262 {
16263 return qe_invalid;
16264 }
16265 650352 }
16266
16267
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>5)
16268 {
16269
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags7),f))
16270 {
16271 return qe_invalid;
16272 }
16273
16274
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags8),f))
16275 {
16276 return qe_invalid;
16277 }
16278
16279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags9),f))
16280 {
16281 return qe_invalid;
16282 }
16283
16284
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags10),f))
16285 {
16286 return qe_invalid;
16287 }
16288
16289
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->csensitive),f))
16290 {
16291 return qe_invalid;
16292 }
16293 650352 }
16294 else
16295 {
16296 528504 temp_mapscr->csensitive=1;
16297 }
16298
16299
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<14) // August 2007: screen SFX added
16300 {
16301
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16302 {
16303 994 temp_mapscr->bosssfx=
16304
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16305 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16306 WAV_ROAR;
16307 994 }
16308
16309
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16310 {
16311 170 temp_mapscr->oceansfx=WAV_SEA;
16312 170 }
16313
16314 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16315 ? 0 : WAV_SECRET;
16316
16317 528504 temp_mapscr->flags3 &= ~66; //64|2
16318 528504 temp_mapscr->flags2 &= ~32;
16319 528504 temp_mapscr->flags &= ~136; // 128|8
16320 528504 }
16321 else
16322 {
16323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->oceansfx),f))
16324 {
16325 return qe_invalid;
16326 }
16327
16328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->bosssfx),f))
16329 {
16330 return qe_invalid;
16331 }
16332
16333
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->secretsfx),f))
16334 {
16335 return qe_invalid;
16336 }
16337 }
16338
16339
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<15) // October 2007: another SFX
16340 {
16341 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16342 528504 }
16343 else
16344 {
16345
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16346 {
16347 return qe_invalid;
16348 }
16349 }
16350
16351
16352
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16353 {
16354
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16355 {
16356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16357 {
16358 return qe_invalid;
16359 }
16360 6940080 }
16361
16362
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 6940080 times.
8096760 for(int32_t k=0; k<6; k++)
16363 {
16364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16365 {
16366 return qe_invalid;
16367 }
16368 6940080 }
16369 1156680 }
16370
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16371 {
16372 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16373 {
16374 return qe_invalid;
16375 }
16376
16377 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16378 {
16379 return qe_invalid;
16380 }
16381
16382 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16383 {
16384 return qe_invalid;
16385 }
16386
16387 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16388
16389 {
16390 return qe_invalid;
16391 }
16392 }
16393
16394
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>149))
16395 {
16396
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16397 {
16398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16399 {
16400 return qe_invalid;
16401 }
16402 16320 }
16403
16404
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16405 {
16406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16407 {
16408 return qe_invalid;
16409 }
16410 16320 }
16411
16412
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16413 {
16414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16415 {
16416 return qe_invalid;
16417 }
16418 16320 }
16419
16420
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16421 {
16422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16423 {
16424 return qe_invalid;
16425 }
16426 16320 }
16427
16428
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16429 {
16430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16431 {
16432 return qe_invalid;
16433 }
16434 16320 }
16435
16436
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16437 {
16438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16439 {
16440 return qe_invalid;
16441 }
16442 16320 }
16443 2720 }
16444
16445
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16446 {
16447
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16448 {
16449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16450 {
16451 return qe_invalid;
16452 }
16453 6940080 }
16454 1156680 }
16455
16456
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16457 {
16458
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 if((Header->zelda_version == 0x192)&&(Header->build>153))
16459 {
16460
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16461 {
16462 return qe_invalid;
16463 }
16464 2720 }
16465
16466
1/2
✓ Branch 0 taken 1156680 times.
✗ Branch 1 not taken.
1156680 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16467 {
16468 return qe_invalid;
16469 }
16470 1156680 }
16471
16472
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16473 {
16474 22176 extras=15;
16475 22176 }
16476
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16477 {
16478 extras=11;
16479 }
16480
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16481 {
16482 extras=32;
16483 }
16484
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16485 {
16486 extras=64;
16487 }
16488
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 else if(Header->zelda_version < 0x193)
16489 {
16490 2720 extras=62;
16491 2720 }
16492 else
16493
16494 {
16495 1153960 extras=0;
16496 }
16497
16498
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1178856 times.
1680136 for(int32_t k=0; k<extras; k++)
16499 {
16500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16501 {
16502 return qe_invalid;
16503 }
16504 501280 }
16505
16506
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16507 //if (version>3)
16508 {
16509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->nextmap),f))
16510 {
16511 return qe_invalid;
16512 }
16513
16514
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->nextscr),f))
16515 {
16516 return qe_invalid;
16517 }
16518 650352 }
16519 else
16520 {
16521 528504 temp_mapscr->nextmap=0;
16522 528504 temp_mapscr->nextscr=0;
16523 }
16524
16525
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16526 {
16527 22176 secretcombos=20;
16528 22176 }
16529
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16530 {
16531 secretcombos=256;
16532 }
16533 else
16534 {
16535 1156680 secretcombos=128;
16536 }
16537
16538
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16539 {
16540
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16541 {
16542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16543 {
16544 return qe_invalid;
16545 }
16546
16547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16548 {
16549 443520 temp_mapscr->secretcombo[k]=tempbyte;
16550 443520 }
16551 443520 }
16552 22176 }
16553 else
16554 {
16555
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16556 {
16557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16558 {
16559 return qe_invalid;
16560 }
16561
16562 148055040 }
16563 }
16564
16565
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16566 {
16567
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16568 {
16569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16570 {
16571 return qe_invalid;
16572 }
16573 148055040 }
16574
16575
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16576 {
16577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16578 {
16579 return qe_invalid;
16580 }
16581 148055040 }
16582 1156680 }
16583
16584
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16585 {
16586 if(!p_getc(&padding,f))
16587 {
16588 return qe_invalid;
16589 }
16590 }
16591
16592
2/2
✓ Branch 0 taken 207478656 times.
✓ Branch 1 taken 1178856 times.
208657512 for(int32_t k=0; k<176; k++)
16593 {
16594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207478656 times.
207478656 if(!p_igetw(&(temp_mapscr->data[k]),f))
16595 {
16596 return qe_invalid;
16597 }
16598 207478656 }
16599
16600
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16601 {
16602 if(!p_getc(&padding,f))
16603 {
16604 return qe_invalid;
16605 }
16606
16607 if(!p_getc(&padding,f))
16608 {
16609 return qe_invalid;
16610 }
16611 }
16612
16613
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16614 {
16615
2/2
✓ Branch 0 taken 203575680 times.
✓ Branch 1 taken 1156680 times.
204732360 for(int32_t k=0; k<176; k++)
16616 {
16617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16618 {
16619 return qe_invalid;
16620 }
16621
16622
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 203096960 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
203575680 if((Header->zelda_version == 0x192)&&(Header->build<24))
16623 {
16624 if(!p_getc(&tempbyte,f))
16625 {
16626 return qe_invalid;
16627 }
16628
16629 if(!p_getc(&tempbyte,f))
16630 {
16631 return qe_invalid;
16632 }
16633
16634 if(!p_getc(&tempbyte,f))
16635 {
16636 return qe_invalid;
16637 }
16638 }
16639 203575680 }
16640 1156680 }
16641
16642
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16643 {
16644
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 203575680 times.
204732360 for(int32_t k=0; k<176; k++)
16645 {
16646
16647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->cset[k]),f))
16648 {
16649 return qe_invalid;
16650 }
16651 203575680 }
16652 1156680 }
16653
16654
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16655 {
16656 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16657 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_page<<8);
16658 22176 }
16659
16660
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16661 {
16662 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16663 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16664 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16665 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16666 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16667 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16668 22176 }
16669
16670
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16671 {
16672
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16673 {
16674
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16675 {
16676 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16677 {
16678 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16679 }
16680 }
16681 else
16682 {
16683
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16684 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16685 {
16686 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16687 3902976 }
16688
16689 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16690 }
16691
16692 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_page<<8);
16693 3902976 }
16694 22176 }
16695
16696 /*if(version>12)
16697 {
16698 if(!p_getc(&(temp_mapscr->scrWidth),f))
16699 {
16700 return qe_invalid;
16701 }
16702 if(!p_getc(&(temp_mapscr->scrHeight),f))
16703 {
16704 return qe_invalid;
16705 }
16706 }*/
16707
16708
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>4)
16709 {
16710 int16_t m;
16711
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&m, f))
16712 return qe_invalid;
16713
2/2
✓ Branch 0 taken 644307 times.
✓ Branch 1 taken 6045 times.
650352 if (m <= 0)
16714 644307 temp_mapscr->music = vbound(m, 0, -1);
16715
1/2
✓ Branch 0 taken 6045 times.
✗ Branch 1 not taken.
6045 else if (!keep_music) // can't safely convert without modifying quest_music, so just use -1
16716 temp_mapscr->music = -1;
16717 6045 else temp_mapscr->music = find_or_make_midi_music(convert_from_old_midi_id(m + (MIDIOFFSET_MAPSCR - MIDIOFFSET_ZSCRIPT),true));
16718 650352 }
16719 else
16720 {
16721 528504 temp_mapscr->music = -1;
16722 }
16723
16724
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>=17)
16725 {
16726
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->lens_layer),f))
16727 {
16728 return qe_invalid;
16729 }
16730 650352 }
16731 else
16732 {
16733 528504 temp_mapscr->lens_layer = llNORMAL;
16734 }
16735
16736
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version>6)
16737 {
16738 dword bits;
16739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_igetl(&bits,f))
16740 {
16741 return qe_invalid;
16742 }
16743
16744 int32_t m;
16745 float tempfloat;
16746 word tempw;
16747 650352 temp_mapscr->ffcCountMarkDirty();
16748 650352 temp_mapscr->ffcs.clear();
16749 650352 temp_mapscr->resizeFFC(std::bit_width(bits));
16750
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 20811264 times.
21461616 for(m=0; m<32; m++)
16751 {
16752
2/2
✓ Branch 0 taken 20536512 times.
✓ Branch 1 taken 274752 times.
20811264 if((bits>>m)&1)
16753 {
16754 274752 ffcdata& tempffc = temp_mapscr->ffcs[m];
16755
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetw(&tempw,f))
16756 {
16757 return qe_invalid;
16758 }
16759 274752 tempffc.data = tempw;
16760
16761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.cset),f))
16762 {
16763 return qe_invalid;
16764 }
16765
16766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.delay),f))
16767 {
16768 return qe_invalid;
16769 }
16770
16771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version < 9)
16772 {
16773 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16774 {
16775 return qe_invalid;
16776 }
16777
16778 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16779
16780 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16781 {
16782 return qe_invalid;
16783 }
16784
16785 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16786
16787 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16788 {
16789 return qe_invalid;
16790 }
16791
16792 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16793
16794 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16795 {
16796 return qe_invalid;
16797 }
16798
16799 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16800
16801 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16802 {
16803 return qe_invalid;
16804 }
16805
16806 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16807
16808 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16809 {
16810 return qe_invalid;
16811 }
16812
16813 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16814 }
16815 else
16816 {
16817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.x),f))
16818 {
16819 return qe_invalid;
16820 }
16821
16822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.y),f))
16823 {
16824 return qe_invalid;
16825 }
16826
16827
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetzf(&(tempffc.vx),f))
16828 {
16829 return qe_invalid;
16830 }
16831
16832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.vy),f))
16833 {
16834 return qe_invalid;
16835 }
16836
16837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ax),f))
16838 {
16839 return qe_invalid;
16840 }
16841
16842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ay),f))
16843 {
16844 return qe_invalid;
16845 }
16846 }
16847
16848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.link),f))
16849 {
16850 return qe_invalid;
16851 }
16852
16853
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>7)
16854 {
16855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16856 {
16857 return qe_invalid;
16858 }
16859
16860 274752 tempffc.hit_width = (tempbyte&0x3F)+1;
16861 274752 tempffc.txsz = (tempbyte>>6)+1;
16862
16863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16864 {
16865 return qe_invalid;
16866 }
16867
16868 274752 tempffc.hit_height = (tempbyte&0x3F)+1;
16869 274752 tempffc.tysz = (tempbyte>>6)+1;
16870
16871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.flags),f))
16872 {
16873 return qe_invalid;
16874 }
16875 274752 }
16876 else
16877 {
16878 tempffc.hit_width=16;
16879 tempffc.hit_height=16;
16880 tempffc.txsz=1;
16881 tempffc.tysz=1;
16882 tempffc.flags=ffc_none;
16883 }
16884
16885 274752 tempffc.updateSolid();
16886
16887
16888
4/6
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268748 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 268748 times.
274752 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16889 {
16890 tempffc.flags|=ffc_ignoreholdup;
16891 }
16892
16893
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>9)
16894 {
16895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.script),f))
16896 {
16897 return qe_invalid;
16898 }
16899 274752 }
16900 else
16901 {
16902 tempffc.script=0;
16903 }
16904
16905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version>10)
16906 {
16907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[0]),f))
16908 {
16909 return qe_invalid;
16910 }
16911
16912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[1]),f))
16913 {
16914 return qe_invalid;
16915 }
16916
16917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[2]),f))
16918 {
16919 return qe_invalid;
16920 }
16921
16922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[3]),f))
16923 {
16924 return qe_invalid;
16925 }
16926
16927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[4]),f))
16928 {
16929 return qe_invalid;
16930 }
16931
16932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[5]),f))
16933 {
16934 return qe_invalid;
16935 }
16936
16937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[6]),f))
16938 {
16939 return qe_invalid;
16940 }
16941
16942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[7]),f))
16943 {
16944 return qe_invalid;
16945 }
16946
16947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
16948 {
16949 return qe_invalid;
16950 }
16951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
16952 {
16953 return qe_invalid;
16954 }
16955 274752 }
16956
16957
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16958 {
16959 tempffc.script = 0;
16960 for(int q = 0; q < 8; ++q)
16961 tempffc.initd[q] = 0;
16962 }
16963
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version <= 11)
16964 {
16965 fixffcs=true;
16966 }
16967 274752 }
16968 20811264 }
16969
16970 650352 temp_mapscr->shrinkToFitFFCs();
16971 650352 }
16972
16973
16974 //add in the new whistle flags
16975
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version<13)
16976 {
16977
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16978 {
16979 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16980 124 }
16981 528504 }
16982
16983 //2.55 starts here
16984
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 19 && Header->zelda_version > 0x253 )
16985 {
16986 // mapscr fields that were never used, so are now removed:
16987 // int32_t npcstrings[10];
16988 // int16_t new_items[10];
16989 // int16_t new_item_x[10];
16990 // int16_t new_item_y[10];
16991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16992 {
16993 return qe_invalid;
16994 }
16995 34408 }
16996
16997
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 20 && Header->zelda_version > 0x253 )
16998 {
16999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
17000 {
17001 return qe_invalid;
17002 }
17003
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
17004 {
17005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17006 {
17007 return qe_invalid;
17008 }
17009 275264 }
17010 34408 }
17011
2/2
✓ Branch 0 taken 1144448 times.
✓ Branch 1 taken 34408 times.
1178856 if ( version < 20 )
17012 {
17013 1144448 temp_mapscr->script = 0;
17014
2/2
✓ Branch 0 taken 9155584 times.
✓ Branch 1 taken 1144448 times.
10300032 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
17015 1144448 }
17016
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 21 && Header->zelda_version > 0x253 )
17017 {
17018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
17019 {
17020 return qe_invalid;
17021 }
17022 34408 }
17023
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 21 )
17024 {
17025 1144448 temp_mapscr->preloadscript = 0;
17026 1144448 }
17027
17028
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
17029 {
17030
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
17031 {
17032 return qe_invalid;
17033 }
17034
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
17035 {
17036 return qe_invalid;
17037 }
17038 34408 }
17039
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 22 )
17040 {
17041 1144448 temp_mapscr->hidelayers = 0;
17042 1144448 temp_mapscr->hidescriptlayers = 0;
17043 1144448 }
17044
17045 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
17046 //May be any version before 2.11. -Z
17047 /* --not the roar, the HIT SFX
17048 if ( Header->zelda_version <= 0x210 )
17049 {
17050 if ( temp_mapscr->bosssfx == WAV_DODONGO )
17051 {
17052 temp_mapscr->bosssfx = WAV_ROAR;
17053 }
17054 }
17055 */
17056
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
17057 {
17058
1/2
✓ Branch 0 taken 4715424 times.
✗ Branch 1 not taken.
4715424 if(temp_mapscr->door[k] == dNONE)
17059 temp_mapscr->door[k] = dWALL;
17060 4715424 }
17061
17062 1178856 return 0;
17063 1178856 }
17064 1563056 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind, bool keep_music)
17065 {
17066
2/2
✓ Branch 0 taken 1178856 times.
✓ Branch 1 taken 384200 times.
1563056 if(version < 23)
17067 {
17068 1178856 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind,keep_music);
17069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(ret) return ret;
17070 1178856 }
17071 else
17072 {
17073
1/2
✓ Branch 0 taken 384200 times.
✗ Branch 1 not taken.
384200 if(!p_getc(&(temp_mapscr->valid),f))
17074 return qe_invalid;
17075
2/2
✓ Branch 0 taken 194017 times.
✓ Branch 1 taken 190183 times.
384200 if(!(temp_mapscr->valid & mVALID))
17076 {
17077 190183 int map = scrind/MAPSCRS;
17078 190183 int screen = scrind%MAPSCRS;
17079
4/6
✓ Branch 0 taken 183081 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 183081 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 183081 times.
190183 if(version > 25 && scrind > -1 && map < map_infos.size())
17080 {
17081 183081 auto const& mapinf = map_infos[map];
17082 //Empty screen, apply defaults
17083
2/2
✓ Branch 0 taken 1098486 times.
✓ Branch 1 taken 183081 times.
1281567 for(int q = 0; q < 6; ++q)
17084 {
17085 1098486 auto layermap = mapinf.autolayers[q];
17086 1098486 temp_mapscr->layermap[q] = layermap;
17087
2/2
✓ Branch 0 taken 1026888 times.
✓ Branch 1 taken 71598 times.
1098486 if(layermap)
17088 71598 temp_mapscr->layerscreen[q] = screen;
17089 1098486 }
17090 183081 temp_mapscr->color = mapinf.autopalette;
17091 183081 }
17092 190183 return 0;
17093 }
17094 uint32_t scr_has_flags;
17095
1/2
✓ Branch 0 taken 194017 times.
✗ Branch 1 not taken.
194017 if(!p_igetl(&scr_has_flags,f))
17096 return qe_invalid;
17097
17098
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 183559 times.
194017 if(scr_has_flags & SCRHAS_ROOMDATA)
17099 {
17100
1/2
✓ Branch 0 taken 183559 times.
✗ Branch 1 not taken.
183559 if(!p_getc(&(temp_mapscr->guy),f))
17101 return qe_invalid;
17102
2/2
✓ Branch 0 taken 183439 times.
✓ Branch 1 taken 120 times.
183559 if(version > 26)
17103 {
17104
1/2
✓ Branch 0 taken 183439 times.
✗ Branch 1 not taken.
183439 if(!p_igetl(&(temp_mapscr->guytile),f))
17105 return qe_invalid;
17106
1/2
✓ Branch 0 taken 183439 times.
✗ Branch 1 not taken.
183439 if(!p_getc(&(temp_mapscr->guycs),f))
17107 return qe_invalid;
17108
1/2
✓ Branch 0 taken 183439 times.
✗ Branch 1 not taken.
183439 if(!p_igetw(&(temp_mapscr->roomflags),f))
17109 return qe_invalid;
17110 183439 }
17111 else
17112 {
17113 120 temp_mapscr->guytile = -1; //signal to use default guy values
17114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
17115
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
17116 }
17117
1/2
✓ Branch 0 taken 183559 times.
✗ Branch 1 not taken.
183559 if(!p_igetw(&(temp_mapscr->str),f))
17118 return qe_invalid;
17119
1/2
✓ Branch 0 taken 183559 times.
✗ Branch 1 not taken.
183559 if(!p_getc(&(temp_mapscr->room),f))
17120 return qe_invalid;
17121
1/2
✓ Branch 0 taken 183559 times.
✗ Branch 1 not taken.
183559 if(!p_igetw(&(temp_mapscr->catchall),f))
17122 return qe_invalid;
17123 183559 }
17124
2/2
✓ Branch 0 taken 189130 times.
✓ Branch 1 taken 4887 times.
194017 if(scr_has_flags & SCRHAS_ITEM)
17125 {
17126
1/2
✓ Branch 0 taken 4887 times.
✗ Branch 1 not taken.
4887 if(!p_getc(&(temp_mapscr->item),f))
17127 return qe_invalid;
17128
1/2
✓ Branch 0 taken 4887 times.
✗ Branch 1 not taken.
4887 if(!p_getc(&(temp_mapscr->hasitem),f))
17129 return qe_invalid;
17130
1/2
✓ Branch 0 taken 4887 times.
✗ Branch 1 not taken.
4887 if(!p_getc(&(temp_mapscr->itemx),f))
17131 return qe_invalid;
17132
1/2
✓ Branch 0 taken 4887 times.
✗ Branch 1 not taken.
4887 if(!p_getc(&(temp_mapscr->itemy),f))
17133 return qe_invalid;
17134 4887 }
17135
2/2
✓ Branch 0 taken 176089 times.
✓ Branch 1 taken 17928 times.
194017 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17136 {
17137
1/2
✓ Branch 0 taken 17928 times.
✗ Branch 1 not taken.
17928 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17138 return qe_invalid;
17139 17928 }
17140
2/2
✓ Branch 0 taken 186909 times.
✓ Branch 1 taken 7108 times.
194017 if(scr_has_flags & SCRHAS_TWARP)
17141 {
17142
2/2
✓ Branch 0 taken 28432 times.
✓ Branch 1 taken 7108 times.
35540 for(int32_t i=0; i<4; i++)
17143 {
17144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28432 times.
28432 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17145 return qe_invalid;
17146 28432 }
17147
2/2
✓ Branch 0 taken 28432 times.
✓ Branch 1 taken 7108 times.
35540 for(int32_t i=0; i<4; i++)
17148 {
17149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28432 times.
28432 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17150 return qe_invalid;
17151 28432 }
17152
2/2
✓ Branch 0 taken 28432 times.
✓ Branch 1 taken 7108 times.
35540 for(int32_t i=0; i<4; i++)
17153 {
17154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28432 times.
28432 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17155 return qe_invalid;
17156 28432 }
17157
1/2
✓ Branch 0 taken 7108 times.
✗ Branch 1 not taken.
7108 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17158 return qe_invalid;
17159 7108 }
17160
2/2
✓ Branch 0 taken 181785 times.
✓ Branch 1 taken 12232 times.
194017 if(scr_has_flags & SCRHAS_SWARP)
17161 {
17162
2/2
✓ Branch 0 taken 48928 times.
✓ Branch 1 taken 12232 times.
61160 for(int32_t i=0; i<4; i++)
17163 {
17164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48928 times.
48928 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17165 return qe_invalid;
17166 48928 }
17167
2/2
✓ Branch 0 taken 48928 times.
✓ Branch 1 taken 12232 times.
61160 for(int32_t i=0; i<4; i++)
17168 {
17169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48928 times.
48928 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17170 return qe_invalid;
17171 48928 }
17172
2/2
✓ Branch 0 taken 48928 times.
✓ Branch 1 taken 12232 times.
61160 for(int32_t i=0; i<4; i++)
17173 {
17174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48928 times.
48928 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17175 return qe_invalid;
17176 48928 }
17177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12232 times.
12232 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17178 return qe_invalid;
17179
1/2
✓ Branch 0 taken 12232 times.
✗ Branch 1 not taken.
12232 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17180 return qe_invalid;
17181 12232 }
17182
2/2
✓ Branch 0 taken 181184 times.
✓ Branch 1 taken 12833 times.
194017 if(scr_has_flags & SCRHAS_WARPRET)
17183 {
17184
2/2
✓ Branch 0 taken 51332 times.
✓ Branch 1 taken 12833 times.
64165 for(int32_t i=0; i<4; i++)
17185 {
17186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51332 times.
51332 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17187 return qe_invalid;
17188 51332 }
17189
2/2
✓ Branch 0 taken 51332 times.
✓ Branch 1 taken 12833 times.
64165 for(int32_t i=0; i<4; i++)
17190 {
17191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51332 times.
51332 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17192 return qe_invalid;
17193 51332 }
17194
1/2
✓ Branch 0 taken 12833 times.
✗ Branch 1 not taken.
12833 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17195 return qe_invalid;
17196
1/2
✓ Branch 0 taken 12833 times.
✗ Branch 1 not taken.
12833 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17197 return qe_invalid;
17198 12833 }
17199
2/2
✓ Branch 0 taken 165284 times.
✓ Branch 1 taken 28733 times.
194017 if(scr_has_flags & SCRHAS_LAYERS)
17200 {
17201
2/2
✓ Branch 0 taken 172398 times.
✓ Branch 1 taken 28733 times.
201131 for(int32_t k=0; k<6; k++)
17202 {
17203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172398 times.
172398 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17204 return qe_invalid;
17205 172398 }
17206
2/2
✓ Branch 0 taken 172398 times.
✓ Branch 1 taken 28733 times.
201131 for(int32_t k=0; k<6; k++)
17207 {
17208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172398 times.
172398 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17209 return qe_invalid;
17210 172398 }
17211
2/2
✓ Branch 0 taken 172398 times.
✓ Branch 1 taken 28733 times.
201131 for(int32_t k=0; k<6; k++)
17212 {
17213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172398 times.
172398 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17214 return qe_invalid;
17215 172398 }
17216
1/2
✓ Branch 0 taken 28733 times.
✗ Branch 1 not taken.
28733 if(!p_getc(&(temp_mapscr->hidelayers),f))
17217 return qe_invalid;
17218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28733 times.
28733 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17219 return qe_invalid;
17220 28733 }
17221
2/2
✓ Branch 0 taken 193913 times.
✓ Branch 1 taken 104 times.
194017 if(scr_has_flags & SCRHAS_MAZE)
17222 {
17223
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
17224 {
17225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
17226 return qe_invalid;
17227 416 }
17228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
17229 return qe_invalid;
17230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
17231 {
17232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
17233 return qe_invalid;
17234 104 }
17235 104 }
17236
2/2
✓ Branch 0 taken 148265 times.
✓ Branch 1 taken 45752 times.
194017 if(scr_has_flags & SCRHAS_D_S_U)
17237 {
17238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148265 times.
148265 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17239 return qe_invalid;
17240
2/2
✓ Branch 0 taken 593060 times.
✓ Branch 1 taken 148265 times.
741325 for(int32_t k=0; k<4; k++)
17241 {
17242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 593060 times.
593060 if(!p_getc(&(temp_mapscr->door[k]),f))
17243 return qe_invalid;
17244
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 592700 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
593060 if(version < 29 && temp_mapscr->door[k] == dNONE)
17245 temp_mapscr->door[k] = dWALL;
17246 593060 }
17247
17248
1/2
✓ Branch 0 taken 148265 times.
✗ Branch 1 not taken.
148265 if(!p_getc(&(temp_mapscr->stairx),f))
17249 return qe_invalid;
17250
17251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148265 times.
148265 if(!p_getc(&(temp_mapscr->stairy),f))
17252 return qe_invalid;
17253
1/2
✓ Branch 0 taken 148265 times.
✗ Branch 1 not taken.
148265 if(!p_igetw(&(temp_mapscr->undercombo),f))
17254 return qe_invalid;
17255
1/2
✓ Branch 0 taken 148265 times.
✗ Branch 1 not taken.
148265 if(!p_getc(&(temp_mapscr->undercset),f))
17256 return qe_invalid;
17257 148265 }
17258
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 35264 times.
45752 else if(version < 29)
17259 {
17260
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17261 41952 temp_mapscr->door[k] = dWALL;
17262 10488 }
17263
2/2
✓ Branch 0 taken 179054 times.
✓ Branch 1 taken 14963 times.
194017 if(scr_has_flags & SCRHAS_FLAGS)
17264 {
17265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14963 times.
14963 if(!p_getc(&(temp_mapscr->flags),f))
17266 return qe_invalid;
17267
1/2
✓ Branch 0 taken 14963 times.
✗ Branch 1 not taken.
14963 if(!p_getc(&(temp_mapscr->flags2),f))
17268 return qe_invalid;
17269
1/2
✓ Branch 0 taken 14963 times.
✗ Branch 1 not taken.
14963 if(!p_getc(&(temp_mapscr->flags3),f))
17270 return qe_invalid;
17271
1/2
✓ Branch 0 taken 14963 times.
✗ Branch 1 not taken.
14963 if(!p_getc(&(temp_mapscr->flags4),f))
17272 return qe_invalid;
17273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14963 times.
14963 if(!p_getc(&(temp_mapscr->flags5),f))
17274 return qe_invalid;
17275
1/2
✓ Branch 0 taken 14963 times.
✗ Branch 1 not taken.
14963 if(!p_getc(&(temp_mapscr->flags6),f))
17276 return qe_invalid;
17277
1/2
✓ Branch 0 taken 14963 times.
✗ Branch 1 not taken.
14963 if(!p_getc(&(temp_mapscr->flags7),f))
17278 return qe_invalid;
17279
1/2
✓ Branch 0 taken 14963 times.
✗ Branch 1 not taken.
14963 if(!p_getc(&(temp_mapscr->flags8),f))
17280 return qe_invalid;
17281
1/2
✓ Branch 0 taken 14963 times.
✗ Branch 1 not taken.
14963 if(!p_getc(&(temp_mapscr->flags9),f))
17282 return qe_invalid;
17283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14963 times.
14963 if(!p_getc(&(temp_mapscr->flags10),f))
17284 return qe_invalid;
17285
1/2
✓ Branch 0 taken 14963 times.
✗ Branch 1 not taken.
14963 if(!p_getc(&(temp_mapscr->flags11),f))
17286 return qe_invalid;
17287 14963 }
17288
2/2
✓ Branch 0 taken 180296 times.
✓ Branch 1 taken 13721 times.
194017 if(scr_has_flags & SCRHAS_ENEMY)
17289 {
17290
2/2
✓ Branch 0 taken 137210 times.
✓ Branch 1 taken 13721 times.
150931 for(int32_t k=0; k<10; k++)
17291 {
17292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137210 times.
137210 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17293 return qe_invalid;
17294
1/2
✓ Branch 0 taken 137210 times.
✗ Branch 1 not taken.
137210 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17295 temp_mapscr->enemy[k] = 0;
17296 137210 }
17297
1/2
✓ Branch 0 taken 13721 times.
✗ Branch 1 not taken.
13721 if(!p_getc(&(temp_mapscr->pattern),f))
17298 return qe_invalid;
17299 13721 }
17300
2/2
✓ Branch 0 taken 153821 times.
✓ Branch 1 taken 40196 times.
194017 if(scr_has_flags & SCRHAS_CARRY)
17301 {
17302
2/2
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 153483 times.
153821 if(version < 34)
17303 {
17304 word tmpw;
17305
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 if(!p_igetw(&tmpw,f))
17306 return qe_invalid;
17307 338 temp_mapscr->noreset = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED;
17308
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 if(!p_igetw(&tmpw,f))
17309 return qe_invalid;
17310 676 temp_mapscr->nocarry = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED |
17311 338 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17312 338 }
17313 else
17314 {
17315
1/2
✓ Branch 0 taken 153483 times.
✗ Branch 1 not taken.
153483 if(!p_igetl(&(temp_mapscr->noreset),f))
17316 return qe_invalid;
17317
1/2
✓ Branch 0 taken 153483 times.
✗ Branch 1 not taken.
153483 if(!p_igetl(&(temp_mapscr->nocarry),f))
17318 return qe_invalid;
17319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153483 times.
153483 if(!p_igetl(&(temp_mapscr->exstate_reset),f))
17320 return qe_invalid;
17321
1/2
✓ Branch 0 taken 153483 times.
✗ Branch 1 not taken.
153483 if(!p_igetl(&(temp_mapscr->exstate_carry),f))
17322 return qe_invalid;
17323 }
17324
1/2
✓ Branch 0 taken 153821 times.
✗ Branch 1 not taken.
153821 if(!p_getc(&(temp_mapscr->nextmap),f))
17325 return qe_invalid;
17326
1/2
✓ Branch 0 taken 153821 times.
✗ Branch 1 not taken.
153821 if(!p_getc(&(temp_mapscr->nextscr),f))
17327 return qe_invalid;
17328 153821 }
17329 else
17330 {
17331
2/2
✓ Branch 0 taken 757 times.
✓ Branch 1 taken 39439 times.
40196 if(version < 34)
17332 {
17333 39439 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
17334 39439 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
17335 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17336 39439 }
17337 }
17338
2/2
✓ Branch 0 taken 193288 times.
✓ Branch 1 taken 729 times.
194017 if(scr_has_flags & SCRHAS_SCRIPT)
17339 {
17340
1/2
✓ Branch 0 taken 729 times.
✗ Branch 1 not taken.
729 if(!p_igetw(&(temp_mapscr->script),f))
17341 return qe_invalid;
17342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 729 times.
729 if(!p_getc(&(temp_mapscr->preloadscript),f))
17343 return qe_invalid;
17344
2/2
✓ Branch 0 taken 5832 times.
✓ Branch 1 taken 729 times.
6561 for ( int32_t q = 0; q < 8; q++ )
17345 {
17346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5832 times.
5832 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17347 return qe_invalid;
17348 5832 }
17349 729 }
17350
2/2
✓ Branch 0 taken 154366 times.
✓ Branch 1 taken 39651 times.
194017 if(scr_has_flags & SCRHAS_SECRETS)
17351 {
17352
2/2
✓ Branch 0 taken 5075328 times.
✓ Branch 1 taken 39651 times.
5114979 for(int32_t k=0; k<128; k++)
17353 {
17354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5075328 times.
5075328 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17355 return qe_invalid;
17356 5075328 }
17357
2/2
✓ Branch 0 taken 5075328 times.
✓ Branch 1 taken 39651 times.
5114979 for(int32_t k=0; k<128; k++)
17358 {
17359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5075328 times.
5075328 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17360 return qe_invalid;
17361 5075328 }
17362
2/2
✓ Branch 0 taken 5075328 times.
✓ Branch 1 taken 39651 times.
5114979 for(int32_t k=0; k<128; k++)
17363 {
17364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5075328 times.
5075328 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17365 return qe_invalid;
17366 5075328 }
17367 39651 }
17368
2/2
✓ Branch 0 taken 74452 times.
✓ Branch 1 taken 119565 times.
194017 if(scr_has_flags & SCRHAS_COMBOFLAG)
17369 {
17370
2/2
✓ Branch 0 taken 21043440 times.
✓ Branch 1 taken 119565 times.
21163005 for(int32_t k=0; k<176; ++k)
17371 {
17372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21043440 times.
21043440 if(!p_igetw(&(temp_mapscr->data[k]),f))
17373 return qe_invalid;
17374 21043440 }
17375
2/2
✓ Branch 0 taken 21043440 times.
✓ Branch 1 taken 119565 times.
21163005 for(int32_t k=0; k<176; ++k)
17376 {
17377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21043440 times.
21043440 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17378 return qe_invalid;
17379 21043440 }
17380
2/2
✓ Branch 0 taken 21043440 times.
✓ Branch 1 taken 119565 times.
21163005 for(int32_t k=0; k<176; ++k)
17381 {
17382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21043440 times.
21043440 if(!p_getc(&(temp_mapscr->cset[k]),f))
17383 return qe_invalid;
17384 21043440 }
17385 119565 }
17386
1/2
✓ Branch 0 taken 194017 times.
✗ Branch 1 not taken.
194017 if(scr_has_flags & SCRHAS_MISC)
17387 {
17388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194017 times.
194017 if(!p_igetw(&(temp_mapscr->color),f))
17389 return qe_invalid;
17390
1/2
✓ Branch 0 taken 194017 times.
✗ Branch 1 not taken.
194017 if(!p_getc(&(temp_mapscr->csensitive),f))
17391 return qe_invalid;
17392
1/2
✓ Branch 0 taken 194017 times.
✗ Branch 1 not taken.
194017 if(!p_getc(&(temp_mapscr->oceansfx),f))
17393 return qe_invalid;
17394
1/2
✓ Branch 0 taken 194017 times.
✗ Branch 1 not taken.
194017 if(!p_getc(&(temp_mapscr->bosssfx),f))
17395 return qe_invalid;
17396
1/2
✓ Branch 0 taken 194017 times.
✗ Branch 1 not taken.
194017 if(!p_getc(&(temp_mapscr->secretsfx),f))
17397 return qe_invalid;
17398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194017 times.
194017 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17399 return qe_invalid;
17400
1/2
✓ Branch 0 taken 194017 times.
✗ Branch 1 not taken.
194017 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17401 return qe_invalid;
17402
2/2
✓ Branch 0 taken 156969 times.
✓ Branch 1 taken 37048 times.
194017 if (version < 37)
17403 {
17404 int16_t m;
17405
1/2
✓ Branch 0 taken 156969 times.
✗ Branch 1 not taken.
156969 if(!p_igetw(&m, f))
17406 return qe_invalid;
17407
2/2
✓ Branch 0 taken 156879 times.
✓ Branch 1 taken 90 times.
156969 if (m <= 0)
17408 156879 temp_mapscr->music = vbound(m, 0, -1);
17409
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 else if (!keep_music) // can't safely convert without modifying quest_music, so just use -1
17410 temp_mapscr->music = -1;
17411 90 else temp_mapscr->music = find_or_make_midi_music(convert_from_old_midi_id(m + (MIDIOFFSET_MAPSCR - MIDIOFFSET_ZSCRIPT), true));
17412 156969 }
17413
1/2
✓ Branch 0 taken 37048 times.
✗ Branch 1 not taken.
37048 else if (!p_igetl(&(temp_mapscr->music), f))
17414 return qe_invalid;
17415
1/2
✓ Branch 0 taken 194017 times.
✗ Branch 1 not taken.
194017 if(!p_getc(&(temp_mapscr->lens_layer),f))
17416 return qe_invalid;
17417
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 183439 times.
194017 if(version > 27)
17418 {
17419
1/2
✓ Branch 0 taken 183439 times.
✗ Branch 1 not taken.
183439 if(!p_getc(&(temp_mapscr->lens_show),f))
17420 return qe_invalid;
17421
1/2
✓ Branch 0 taken 183439 times.
✗ Branch 1 not taken.
183439 if(!p_getc(&(temp_mapscr->lens_hide),f))
17422 return qe_invalid;
17423 183439 }
17424 194017 }
17425 else
17426 {
17427 temp_mapscr->music = -1;
17428 temp_mapscr->csensitive = 1;
17429 }
17430 //FFC
17431 194017 bool old_ff = version < 25;
17432 194017 dword bits = 0;
17433 194017 word numffc = 32;
17434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194017 times.
194017 if(old_ff)
17435 {
17436 if(!p_igetl(&bits,f))
17437 return qe_invalid;
17438 }
17439 else
17440 {
17441
2/4
✓ Branch 0 taken 194017 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 194017 times.
194017 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17442 return qe_invalid;
17443 }
17444
17445 194017 temp_mapscr->ffcCountMarkDirty();
17446 194017 temp_mapscr->ffcs.clear();
17447 194017 temp_mapscr->resizeFFC(numffc);
17448
17449 byte tempbyte;
17450 word tempw;
17451
4/6
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 193841 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
✓ Branch 4 taken 176 times.
✗ Branch 5 not taken.
194017 static ffcdata nil_ffc;
17452
2/2
✓ Branch 0 taken 1997090 times.
✓ Branch 1 taken 194017 times.
2191107 for(word m = 0; m < numffc; ++m)
17453 {
17454
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1997090 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1997090 if(old_ff && !(bits & (1<<m))) continue;
17455
17456
1/2
✓ Branch 0 taken 1997090 times.
✗ Branch 1 not taken.
1997090 ffcdata& tempffc = (m < MAXFFCS)
17457 1997090 ? temp_mapscr->ffcs[m]
17458 : nil_ffc; //sanity
17459
17460
1/2
✓ Branch 0 taken 1997090 times.
✗ Branch 1 not taken.
1997090 if(!p_igetw(&tempw,f))
17461 return qe_invalid;
17462
3/4
✓ Branch 0 taken 1997090 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28170 times.
✓ Branch 3 taken 1968920 times.
1997090 if(!old_ff && !tempw) //empty ffc, nothing more to load
17463 1968920 continue;
17464 28170 tempffc.data = tempw;
17465
17466
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_getc(&(tempffc.cset),f))
17467 return qe_invalid;
17468
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetw(&(tempffc.delay),f))
17469 return qe_invalid;
17470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_igetzf(&(tempffc.x),f))
17471 return qe_invalid;
17472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_igetzf(&(tempffc.y),f))
17473 return qe_invalid;
17474
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetzf(&(tempffc.vx),f))
17475 return qe_invalid;
17476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_igetzf(&(tempffc.vy),f))
17477 return qe_invalid;
17478
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetzf(&(tempffc.ax),f))
17479 return qe_invalid;
17480
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetzf(&(tempffc.ay),f))
17481 return qe_invalid;
17482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_getc(&(tempffc.link),f))
17483 return qe_invalid;
17484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(version < 24)
17485 {
17486 if(!p_getc(&tempbyte,f))
17487 return qe_invalid;
17488 tempffc.hit_width = (tempbyte&0x3F)+1;
17489 tempffc.txsz = (tempbyte>>6)+1;
17490 if(!p_getc(&tempbyte,f))
17491 return qe_invalid;
17492 tempffc.hit_height = (tempbyte&0x3F)+1;
17493 tempffc.tysz = (tempbyte>>6)+1;
17494 }
17495 else
17496 {
17497
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetl(&(tempffc.hit_width),f))
17498 return qe_invalid;
17499
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetl(&(tempffc.hit_height),f))
17500 return qe_invalid;
17501
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_getc(&(tempffc.txsz),f))
17502 return qe_invalid;
17503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_getc(&(tempffc.tysz),f))
17504 return qe_invalid;
17505 }
17506
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(!p_igetl(&(tempffc.flags),f))
17507 return qe_invalid;
17508 28170 tempffc.updateSolid();
17509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28170 times.
28170 if(!p_igetw(&(tempffc.script),f))
17510 return qe_invalid;
17511
2/2
✓ Branch 0 taken 225360 times.
✓ Branch 1 taken 28170 times.
253530 for(auto q = 0; q < 8; ++q)
17512 {
17513
1/2
✓ Branch 0 taken 225360 times.
✗ Branch 1 not taken.
225360 if(!p_igetl(&(tempffc.initd[q]),f))
17514 return qe_invalid;
17515 225360 }
17516
2/2
✓ Branch 0 taken 7792 times.
✓ Branch 1 taken 20378 times.
28170 if(version < 33)
17517 {
17518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7792 times.
7792 if(!p_getc(&(tempbyte),f))
17519 return qe_invalid;
17520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7792 times.
7792 if(!p_getc(&(tempbyte),f))
17521 return qe_invalid;
17522 7792 }
17523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20378 times.
20378 else if(!p_getc(&(tempffc.layer),f))
17524 return qe_invalid;
17525
17526
1/2
✓ Branch 0 taken 28170 times.
✗ Branch 1 not taken.
28170 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17527 {
17528 tempffc.script = 0;
17529 for(int q = 0; q < 8; ++q)
17530 tempffc.initd[q] = 0;
17531 }
17532 28170 }
17533 //END FFC
17534
2/2
✓ Branch 0 taken 39375 times.
✓ Branch 1 taken 154642 times.
194017 if(version > 29)
17535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154642 times.
154642 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17536 return qe_invalid;
17537
17538
4/4
✓ Branch 0 taken 67960 times.
✓ Branch 1 taken 126057 times.
✓ Branch 2 taken 67858 times.
✓ Branch 3 taken 102 times.
194017 if (version >= 35 && (temp_mapscr->flags10 & fSCREEN_GRAVITY))
17539 {
17540
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (!p_igetzf(&temp_mapscr->screen_gravity, f))
17541 return qe_invalid;
17542
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (!p_igetzf(&temp_mapscr->screen_terminal_v, f))
17543 return qe_invalid;
17544 102 }
17545 }
17546
17547 1372873 temp_mapscr->shrinkToFitFFCs();
17548
17549 1372873 return 0;
17550 1563056 }
17551
17552 498 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17553 {
17554
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17555 498 int32_t screen=0;
17556
17557 498 word version=0;
17558 dword dummy;
17559 int32_t screens_to_read;
17560
17561 498 mapscr temp_mapscr{};
17562 word temp_map_count;
17563 dword section_size;
17564
17565
5/6
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
498 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17566 {
17567 18 screens_to_read=MAPSCRS192b136;
17568 18 }
17569 else
17570 {
17571 480 screens_to_read=MAPSCRS;
17572 }
17573
17574
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 if(Header->zelda_version > 0x192)
17575 {
17576 //section version info
17577
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&version,f))
17578 {
17579 return qe_invalid;
17580 }
17581
17582
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (version > V_MAPS)
17583 return qe_version;
17584
17585 474 FFCore.quest_format[vMaps] = version;
17586
17587
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&dummy,f))
17588 {
17589 return qe_invalid;
17590 }
17591
17592 //section size
17593
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&section_size,f))
17594 {
17595 return qe_invalid;
17596 }
17597
17598 //finally... section data
17599
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&temp_map_count,f))
17600 {
17601 return 5;
17602 }
17603 474 }
17604 else
17605 {
17606 24 temp_map_count=map_count;
17607 }
17608
17609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 498 times.
498 if (temp_map_count > MAXMAPS)
17610 {
17611 return qe_invalid;
17612 }
17613
17614
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 1 times.
498 if (!should_skip)
17615 {
17616 497 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17617 497 TheMaps.clear();
17618
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 TheMaps.resize(_mapsSize);
17619 497 old_combo_pages.clear();
17620
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 old_combo_pages.resize(_mapsSize);
17621 497 map_infos.clear();
17622
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 map_infos.resize(temp_map_count);
17623
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 169 times.
497 if(version >= 31)
17624 169 Regions = {};
17625 497 }
17626
17627
4/4
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 12911 times.
✓ Branch 2 taken 12911 times.
✓ Branch 3 taken 498 times.
13409 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17628 {
17629 12911 byte valid=1;
17630
2/2
✓ Branch 0 taken 4238 times.
✓ Branch 1 taken 8673 times.
12911 if(version > 22)
17631 {
17632
2/4
✓ Branch 0 taken 4238 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4238 times.
✗ Branch 3 not taken.
4238 if(!p_getc(&valid,f))
17633 return qe_invalid;
17634 4238 }
17635
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 11498 times.
12911 if(valid)
17636 {
17637
2/2
✓ Branch 0 taken 8803 times.
✓ Branch 1 taken 2695 times.
11498 if (version > 25)
17638 {
17639 2695 auto& mapinf = map_infos[i];
17640
2/2
✓ Branch 0 taken 16170 times.
✓ Branch 1 taken 2695 times.
18865 for(int q = 0; q < 6; ++q)
17641 {
17642
2/4
✓ Branch 0 taken 16170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16170 times.
✗ Branch 3 not taken.
16170 if(!p_igetw(&mapinf.autolayers[q],f))
17643 return qe_invalid;
17644 16170 }
17645
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 1747 times.
2695 if (version >= 36)
17646
2/4
✓ Branch 0 taken 948 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 948 times.
✗ Branch 3 not taken.
948 if(!p_igetw(&mapinf.autopalette,f))
17647 return qe_invalid;
17648 2695 }
17649
17650
2/2
✓ Branch 0 taken 9262 times.
✓ Branch 1 taken 2236 times.
11498 if (version >= 31)
17651 {
17652 static regions_data tmp_rd;
17653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2236 times.
2236 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17654
2/2
✓ Branch 0 taken 17888 times.
✓ Branch 1 taken 2236 times.
20124 for(int32_t j=0; j<8; j++)
17655 {
17656
2/2
✓ Branch 0 taken 143104 times.
✓ Branch 1 taken 17888 times.
160992 for(int32_t k=0; k<8; k++)
17657 {
17658
2/4
✓ Branch 0 taken 143104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 143104 times.
✗ Branch 3 not taken.
143104 if(!p_getc(&rd.region_ids[j][k],f))
17659 {
17660 return qe_invalid;
17661 }
17662 143104 }
17663 17888 }
17664 2236 }
17665 11498 }
17666
2/2
✓ Branch 0 taken 1755224 times.
✓ Branch 1 taken 12911 times.
1768135 for(int32_t j=0; j<screens_to_read; j++)
17667 {
17668 1755224 screen=i*MAPSCRS+j;
17669
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1754952 times.
1755224 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17670 1755224 scr->map = i;
17671 1755224 scr->screen = j;
17672
2/2
✓ Branch 0 taken 1563056 times.
✓ Branch 1 taken 192168 times.
1755224 if(valid)
17673
1/2
✓ Branch 0 taken 1563056 times.
✗ Branch 1 not taken.
1563056 readmapscreen(f, Header, scr, version, screen, !should_skip);
17674
1/2
✓ Branch 0 taken 192168 times.
✗ Branch 1 not taken.
192168 else if (!should_skip)
17675
1/2
✓ Branch 0 taken 192168 times.
✗ Branch 1 not taken.
192168 clear_screen(scr);
17676 1755224 }
17677
17678
2/2
✓ Branch 0 taken 12909 times.
✓ Branch 1 taken 2 times.
12911 if (should_skip)
17679 2 continue;
17680
17681
5/6
✓ Branch 0 taken 12741 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 12723 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
12909 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17682 {
17683 168 int32_t index = (i*MAPSCRS+132);
17684
17685
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17686
17687 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17688 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17689 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17690
17691
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17692 {
17693 504 screen=i*MAPSCRS+j;
17694
17695
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17696 504 TheMaps[screen].valid = mVERSION;
17697 504 TheMaps[screen].music = -1;
17698 504 TheMaps[screen].csensitive = 1;
17699 504 }
17700 168 }
17701
17702
5/6
✓ Branch 0 taken 12741 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 12723 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
12909 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17703 {
17704
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17705 {
17706 22848 screen=i*MAPSCRS+j;
17707
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17708
17709
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17710 {
17711
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17712
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17713
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17714 2924544 }
17715 22848 }
17716 168 }
17717 12909 }
17718 498 map_count = temp_map_count;
17719 498 return 0;
17720 498 }
17721
17722
17723 9237807 void update_combo(newcombo& cmb, word section_version)
17724 {
17725
2/2
✓ Branch 0 taken 1555788 times.
✓ Branch 1 taken 7682019 times.
9237807 if(section_version < 40)
17726 {
17727
3/3
✓ Branch 0 taken 5144 times.
✓ Branch 1 taken 45418 times.
✓ Branch 2 taken 7631457 times.
7682019 switch(cmb.type)
17728 {
17729 case cWATER: case cSHALLOWWATER:
17730 45418 cmb.c_attributes[8 + 6] = iwRipples;
17731 45418 break;
17732 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17733 5144 cmb.c_attributes[8 + 6] = iwTallGrass;
17734 5144 break;
17735 }
17736 7682019 }
17737
2/2
✓ Branch 0 taken 1205450 times.
✓ Branch 1 taken 8032357 times.
9237807 if(section_version < 49)
17738 {
17739
4/4
✓ Branch 0 taken 7997549 times.
✓ Branch 1 taken 34808 times.
✓ Branch 2 taken 15487 times.
✓ Branch 3 taken 7982062 times.
8032357 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17740 50295 cmb.sfx_landing = WAV_ZN1SPLASH;
17741 8032357 }
17742 9237807 }
17743 288 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17744 {
17745
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 264 times.
288 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17746 byte tempbyte;
17747
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17748 {
17749 287 reset_all_combo_animations();
17750 287 init_combo_classes();
17751 287 }
17752
17753 // combos
17754 288 word combos_used=0;
17755 int32_t dummy;
17756 byte padding;
17757 word wpadding;
17758 288 newcombo temp_combo;
17759
17760
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17761
2/2
✓ Branch 0 taken 18735360 times.
✓ Branch 1 taken 287 times.
18735647 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17762
1/2
✓ Branch 0 taken 18735360 times.
✗ Branch 1 not taken.
18735647 combobuf[q].clear();
17763
17764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(version < 0x174)
17765 {
17766 combos_used=1024;
17767 }
17768
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 18 times.
288 else if(version < 0x191)
17769 {
17770 18 combos_used=2048;
17771 18 }
17772 else
17773 {
17774
2/4
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
270 if(!p_igetw(&combos_used,f))
17775 {
17776 return qe_invalid;
17777 }
17778 }
17779
17780 //finally... section data
17781
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 288 times.
7547291 for(int32_t i=0; i<combos_used; i++)
17782 {
17783
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_combo.clear();
17784
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
17785 7547003 int32_t temp_trigflags[6] = {0};
17786
17787
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if ( section_version >= 11 )
17788 {
17789
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17790 {
17791 return qe_invalid;
17792 }
17793 202968 }
17794 else
17795 {
17796
2/4
✓ Branch 0 taken 7344035 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7344035 times.
✗ Branch 3 not taken.
7344035 if(!p_igetw(&temp_combo.tile,f))
17797 {
17798 return qe_invalid;
17799 }
17800 }
17801 7547003 temp_combo.o_tile = temp_combo.tile;
17802
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.flip,f))
17803 {
17804 return qe_invalid;
17805 }
17806
17807
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.walk,f))
17808 {
17809 return qe_invalid;
17810 }
17811
17812
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.type,f))
17813 {
17814 return qe_invalid;
17815 }
17816
17817
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.csets,f))
17818 {
17819 return qe_invalid;
17820 }
17821
17822
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7477229 times.
7547003 if(version < 0x193)
17823 {
17824
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17825 return qe_invalid;
17826
17827
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17828 return qe_invalid;
17829
17830
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17831 {
17832
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17833 {
17834 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17835 {
17836 if(!p_getc(&padding,f))
17837 return qe_invalid;
17838 }
17839 }
17840 36864 }
17841 69774 }
17842
2/2
✓ Branch 0 taken 7510139 times.
✓ Branch 1 taken 36864 times.
7547003 if(version >= 0x192)
17843 {
17844
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.frames,f))
17845 return qe_invalid;
17846
17847
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.speed,f))
17848 return qe_invalid;
17849
17850
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_igetw(&temp_combo.nextcombo,f))
17851 return qe_invalid;
17852
17853
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.nextcset,f))
17854 return qe_invalid;
17855
17856 //Base flag
17857
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=3)
17858
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.flag,f))
17859 return qe_invalid;
17860
17861
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=4)
17862 {
17863
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanim,f))
17864 return qe_invalid;
17865
17866
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_igetw(&temp_combo.nexttimer,f))
17867 return qe_invalid;
17868 4621731 }
17869
17870
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=5)
17871
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanimy,f))
17872 return qe_invalid;
17873
17874
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=6)
17875 {
17876
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.animflags,f))
17877 return qe_invalid;
17878
17879
1/2
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
4621731 if(section_version == 6)
17880 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17881 4621731 }
17882
17883
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=8) //combo Attributes[4] and userflags.
17884 {
17885
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17886
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetzf(&temp_combo.c_attributes[q],f))
17887 return qe_invalid;
17888
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17889 return qe_invalid;
17890
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17891
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17892 return qe_invalid;
17893 202968 }
17894
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=10) //combo trigger flags
17895 {
17896
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17897
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_trigflags[q],f))
17898 return qe_invalid;
17899 202968 }
17900
1/2
✓ Branch 0 taken 7307171 times.
✗ Branch 1 not taken.
7307171 else if(section_version==9) //combo trigger flags, V9 only had two indices
17901 {
17902 for ( int32_t q = 0; q < 2; q++ )
17903 if(!p_igetl(&temp_trigflags[q],f))
17904 return qe_invalid;
17905 }
17906
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 9)
17907
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_trigger.triggerlevel,f))
17908 return qe_invalid;
17909
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 22)
17910
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_trigger.triggerbtn,f))
17911 return qe_invalid;
17912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 24)
17913 {
17914 if(!p_getc(&temp_trigger.triggeritem,f))
17915 return qe_invalid;
17916 if(!p_getc(&tempbyte, f))
17917 return qe_invalid;
17918 temp_trigger.trigtimer = tempbyte;
17919 }
17920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 25)
17921 if(!p_getc(&temp_trigger.trigsfx,f))
17922 return qe_invalid;
17923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 27)
17924 if(!p_igetl(&temp_trigger.trigchange,f))
17925 return qe_invalid;
17926
17927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 29)
17928 {
17929 if(!p_igetw(&temp_trigger.trigprox,f))
17930 return qe_invalid;
17931 if(!p_getc(&tempbyte,f))
17932 return qe_invalid;
17933 temp_trigger.trigctr = tempbyte;
17934 if(!p_igetl(&temp_trigger.trigctramnt,f))
17935 return qe_invalid;
17936 }
17937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 30)
17938 if(!p_getc(&temp_trigger.triglbeam,f))
17939 return qe_invalid;
17940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 31)
17941 {
17942 if(!p_getc(&temp_trigger.trigcschange,f))
17943 return qe_invalid;
17944 if(!p_igetw(&temp_trigger.spawnitem,f))
17945 return qe_invalid;
17946 if(!p_igetw(&temp_trigger.spawnenemy,f))
17947 return qe_invalid;
17948 if(!p_getc(&temp_trigger.exstate,f))
17949 return qe_invalid;
17950 if(!p_igetl(&temp_trigger.spawnip,f))
17951 return qe_invalid;
17952 if(!p_getc(&temp_trigger.trigcopycat,f))
17953 return qe_invalid;
17954 }
17955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 32)
17956 if(!p_getc(&temp_trigger.trigcooldown,f))
17957 return qe_invalid;
17958
17959
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=12) //combo label
17960 {
17961 char label[12];
17962 202968 label[11] = '\0';
17963
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17964
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17965 return qe_invalid;
17966
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17967 202968 }
17968
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7510139 if(section_version >= 13 && section_version < 63) //attribytes[4]
17969 {
17970
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17971 {
17972
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&padding,f))
17973 return qe_invalid;
17974
1/2
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
811872 temp_combo.c_attributes[8 + q] = padding;
17975 811872 }
17976 202968 }
17977 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17978 * This fixes a poor implementation of a ->next flag bug thing.
17979 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17980 * there was a version bump a few weeks before a change that broke stuff.
17981 */
17982
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7510139 if (section_version >= 13 && section_version < 21)
17983 {
17984 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17985 }
17986 //combo scripts
17987
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=14)
17988 {
17989
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17990 return qe_invalid;
17991
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17992
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17993 return qe_invalid;
17994 202968 }
17995
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=15)
17996 {
17997
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17998
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17999
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
18000
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
18001 202968 }
18002
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7510139 if(section_version >= 17 && section_version < 63) //attribytes[4]
18003 {
18004
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18005 {
18006
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&padding,f))
18007 return qe_invalid;
18008
1/2
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
811872 temp_combo.c_attributes[8 + q] = padding;
18009 811872 }
18010
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18011 {
18012
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&wpadding,f))
18013 return qe_invalid;
18014
1/2
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
1623744 temp_combo.c_attributes[16 + q] = int16_t(wpadding);
18015 1623744 }
18016 202968 }
18017
18018
2/2
✓ Branch 0 taken 7477229 times.
✓ Branch 1 taken 32910 times.
7510139 if(version < 0x193)
18019
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
18020
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
18021 32910 return qe_invalid;
18022 7510139 }
18023
18024 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
18025
3/6
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4621731 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7547003 if((version < 0x211)||((version == 0x211)&&(build<7)))
18026 {
18027
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
18028 {
18029
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
18030 {
18031 case 130:
18032 temp_combo.tile = 132;
18033 break;
18034
18035 case 131:
18036 temp_combo.tile = 133;
18037 break;
18038
18039 case 132:
18040 temp_combo.tile = 130;
18041 break;
18042
18043 case 133:
18044 temp_combo.tile = 131;
18045 break;
18046 }
18047 39936 }
18048 2925272 }
18049
18050
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 15)
18051 7344035 temp_combo.o_tile = temp_combo.tile;
18052
18053
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version<18) //upper bits for .walk
18054 7344035 temp_combo.walk |= 0xF0;
18055
18056
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 19)
18057
2/2
✓ Branch 0 taken 29376140 times.
✓ Branch 1 taken 7344035 times.
36720175 for(int32_t q = 0; q < 4; ++q)
18058
1/2
✓ Branch 0 taken 29376140 times.
✗ Branch 1 not taken.
36720175 temp_combo.c_attributes[q] *= 10000;
18059
18060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 23)
18061 {
18062
2/2
✓ Branch 0 taken 15235 times.
✓ Branch 1 taken 7531768 times.
7547003 switch(temp_combo.type) //TRIGFLAG_CMBTYPEFX now required for combotype-specific effects
18063 {
18064 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
18065 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
18066 case cTRIGGERGENERIC: case cCSWITCH:
18067 15235 temp_trigflags[TRIGFLAG_CMBTYPEFX/32] |= 1<<(TRIGFLAG_CMBTYPEFX%32);
18068 15235 }
18069 7547003 }
18070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 25)
18071 {
18072
2/2
✓ Branch 0 taken 27396 times.
✓ Branch 1 taken 7519607 times.
7547003 switch(temp_combo.type)
18073 {
18074 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18075
1/2
✓ Branch 0 taken 27396 times.
✗ Branch 1 not taken.
27396 if(!(temp_combo.usrflags & cflag3))
18076
1/2
✓ Branch 0 taken 27396 times.
✗ Branch 1 not taken.
27396 temp_combo.c_attributes[8 + 3] = WAV_DOOR;
18077 27396 temp_combo.usrflags &= ~cflag3;
18078 27396 break;
18079 }
18080 7547003 }
18081
18082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 26)
18083
2/2
✓ Branch 0 taken 7545882 times.
✓ Branch 1 taken 1121 times.
7548124 if(temp_combo.type == cARMOS)
18084
1/2
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
1121 if(temp_combo.usrflags & cflag1)
18085 temp_combo.usrflags |= cflag3;
18086
18087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 27)
18088 {
18089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(temp_trigflags[0] & 0x00040000) //'next'
18090 temp_trigger.trigchange = 1;
18091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 else if(temp_trigflags[0] & 0x00080000) //'prev'
18092 temp_trigger.trigchange = -1;
18093 7547003 else temp_trigger.trigchange = 0;
18094 7547003 temp_trigflags[0] &= ~(0x00040000|0x00080000);
18095 7547003 }
18096
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 if(section_version < 28)
18097 {
18098
2/2
✓ Branch 0 taken 15512 times.
✓ Branch 1 taken 7531491 times.
7547003 switch(temp_combo.type)
18099 {
18100 case cLOCKBLOCK: case cLOCKEDCHEST:
18101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15512 times.
15512 if(temp_combo.usrflags & cflag7)
18102 temp_combo.usrflags |= cflag8;
18103 15512 else temp_combo.usrflags &= ~cflag8;
18104 15512 temp_combo.usrflags &= ~cflag7;
18105 15512 break;
18106 }
18107
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 7546245 times.
7547003 switch(temp_combo.type)
18108 {
18109 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18110
1/2
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
758 temp_combo.c_attributes[16 + 2] = -1;
18111 758 temp_combo.usrflags |= cflag7;
18112 758 break;
18113 }
18114 7547003 }
18115
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 20)
18116 {
18117 7344035 temp_combo.genflags = 0;
18118
2/2
✓ Branch 0 taken 143987 times.
✓ Branch 1 taken 7200048 times.
7344035 switch(temp_combo.type)
18119 {
18120 case cPUSH_WAIT: case cPUSH_HEAVY:
18121 case cPUSH_HW: case cL_STATUE:
18122 case cR_STATUE: case cPUSH_HEAVY2:
18123 case cPUSH_HW2: case cPOUND:
18124 case cC_STATUE: case cMIRROR:
18125 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18126 case cMAGICPRISM: case cMAGICPRISM4:
18127 case cMAGICSPONGE: case cEYEBALL_A:
18128 case cEYEBALL_B: case cEYEBALL_4:
18129 case cBUSH: case cFLOWERS:
18130 case cLOCKBLOCK: case cLOCKBLOCK2:
18131 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18132 case cCHEST: case cCHEST2:
18133 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18134 case cBOSSCHEST: case cBOSSCHEST2:
18135 case cBUSHNEXT: case cBUSHTOUCHY:
18136 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18137 case cSIGNPOST: case cCSWITCHBLOCK:
18138 case cTORCH: case cTRIGGERGENERIC:
18139
1/2
✓ Branch 0 taken 143987 times.
✗ Branch 1 not taken.
143987 if(temp_combo.usrflags & cflag16)
18140 {
18141 temp_combo.genflags |= cflag1;
18142 temp_combo.usrflags &= ~cflag16;
18143 }
18144 143987 break;
18145 }
18146 7344035 }
18147
18148
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_trigger.trigger_flags.clear();
18149
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 1449024576 times.
1456571579 for(size_t q = 0; q < 32*6; ++q)
18150 {
18151 1449024576 auto ind = q/32;
18152 1449024576 auto bit = 1<<(q%32);
18153
2/2
✓ Branch 0 taken 1449008300 times.
✓ Branch 1 taken 16276 times.
1449024576 if(temp_trigflags[ind] & bit)
18154
1/2
✓ Branch 0 taken 16276 times.
✗ Branch 1 not taken.
16276 temp_trigger.trigger_flags.set(q, true);
18155 1449024576 }
18156
18157
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15274 times.
✓ Branch 3 taken 7531729 times.
7547003 if(temp_trigger.is_blank())
18158 7531729 temp_combo.triggers.clear();
18159
18160
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 update_combo(temp_combo, section_version);
18161
18162
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7532084 times.
✓ Branch 3 taken 14919 times.
7547003 if(i>=start_combo && !should_skip)
18163 {
18164
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18165 {
18166 temp_combo.script = 0;
18167 for(int q = 0; q < 8; ++q)
18168 temp_combo.initd[q] = 0;
18169 }
18170
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 combobuf[i] = temp_combo;
18171 7532084 }
18172 7547003 }
18173
18174
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 1 times.
288 if (should_skip)
18175 1 return 0;
18176
18177
5/6
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
287 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18178 {
18179
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18180 {
18181
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18182 {
18183 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18184 215 }
18185 1501440 }
18186 23 }
18187
18188 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18189
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
287 if(version == 0x210 && get_app_id() != App::zquest)
18190 {
18191
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18192
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
18193 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18194 59 }
18195
18196
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<7)
18197 {
18198
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18199 {
18200
6/9
✓ Branch 0 taken 853 times.
✓ Branch 1 taken 791 times.
✓ Branch 2 taken 603 times.
✓ Branch 3 taken 174 times.
✓ Branch 4 taken 531 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 5350008 times.
5352960 switch(combobuf[tmpcounter].type)
18201 {
18202 case cSLASH:
18203 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
18204 853 break;
18205
18206 case cSLASHITEM:
18207 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18208 791 break;
18209
18210 case cBUSH:
18211 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
18212 603 break;
18213
18214 case cFLOWERS:
18215 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18216 174 break;
18217
18218 case cTALLGRASS:
18219 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18220 531 break;
18221
18222 case cSLASHNEXT:
18223 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18224 break;
18225
18226 case cSLASHNEXTITEM:
18227 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18228 break;
18229
18230 case cBUSHNEXT:
18231 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18232 break;
18233 }
18234 5352960 }
18235 82 }
18236
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
287 if (section_version < 16)
18237 {
18238
2/2
✓ Branch 0 taken 18408960 times.
✓ Branch 1 taken 282 times.
18409242 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18239 {
18240
2/2
✓ Branch 0 taken 18380119 times.
✓ Branch 1 taken 28841 times.
18408960 if (combobuf[tmpcounter].type == cWATER)
18241 {
18242
1/2
✓ Branch 0 taken 28841 times.
✗ Branch 1 not taken.
28841 combobuf[tmpcounter].c_attributes[0] = 4;
18243 28841 }
18244 18408960 }
18245 282 }
18246
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 3 times.
287 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18247 {
18248 3 combobuf[0].walk = 0xF0;
18249 3 combobuf[0].type = 0;
18250 3 combobuf[0].flag = 0;
18251 3 }
18252
18253 //Now for the new combo alias reset
18254
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<2)
18255 {
18256
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18257 {
18258 671744 combo_aliases[j].width = 0;
18259 671744 combo_aliases[j].height = 0;
18260 671744 combo_aliases[j].layermask = 0;
18261
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
18262
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
18263 671744 }
18264 82 }
18265
18266
18267
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations();
18268
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations2();
18269 287 return 0;
18270 288 }
18271
18272 16759 int32_t readcombo_triggers_loop(PACKFILE* f, word s_version, combo_trigger& temp_trigger)
18273 {
18274 byte tempbyte;
18275
2/2
✓ Branch 0 taken 7533 times.
✓ Branch 1 taken 9226 times.
16759 if(s_version >= 52)
18276
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_getcstr(&temp_trigger.label,f))
18277 return qe_invalid;
18278
18279
2/2
✓ Branch 0 taken 7779 times.
✓ Branch 1 taken 8980 times.
16759 if(s_version < 57)
18280 {
18281 7779 int32_t temp_trigflags[6] = {0};
18282 7779 int numtrigs = s_version < 36 ? 3 : 6;
18283
2/2
✓ Branch 0 taken 45816 times.
✓ Branch 1 taken 7779 times.
53595 for ( int32_t q = 0; q < numtrigs; q++ )
18284
1/2
✓ Branch 0 taken 45816 times.
✗ Branch 1 not taken.
45816 if(!p_igetl(&temp_trigflags[q],f))
18285 return qe_invalid;
18286 7779 temp_trigger.trigger_flags.clear();
18287
2/2
✓ Branch 0 taken 1466112 times.
✓ Branch 1 taken 7779 times.
1473891 for(size_t q = 0; q < 32*numtrigs; ++q)
18288 {
18289 1466112 auto ind = q/32;
18290 1466112 auto bit = 1<<(q%32);
18291
2/2
✓ Branch 0 taken 1452438 times.
✓ Branch 1 taken 13674 times.
1466112 if(temp_trigflags[ind] & bit)
18292 13674 temp_trigger.trigger_flags.set(q, true);
18293 1466112 }
18294 7779 }
18295
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 else if(!p_getbitstr(&temp_trigger.trigger_flags,f))
18296 return qe_invalid;
18297
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_igetl(&temp_trigger.triggerlevel,f))
18298 return qe_invalid;
18299
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_getc(&temp_trigger.triggerbtn,f))
18300 return qe_invalid;
18301
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_getc(&temp_trigger.triggeritem,f))
18302 return qe_invalid;
18303
2/2
✓ Branch 0 taken 9226 times.
✓ Branch 1 taken 7533 times.
16759 if(s_version >= 53)
18304 {
18305
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.trigtimer,f))
18306 return qe_invalid;
18307 9226 }
18308 else
18309 {
18310
1/2
✓ Branch 0 taken 7533 times.
✗ Branch 1 not taken.
7533 if(!p_getc(&tempbyte, f))
18311 return qe_invalid;
18312 7533 temp_trigger.trigtimer = tempbyte;
18313 }
18314
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_getc(&temp_trigger.trigsfx,f))
18315 return qe_invalid;
18316
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_igetl(&temp_trigger.trigchange,f))
18317 return qe_invalid;
18318
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_igetw(&temp_trigger.trigprox,f))
18319 return qe_invalid;
18320
2/2
✓ Branch 0 taken 9226 times.
✓ Branch 1 taken 7533 times.
16759 if(s_version >= 53)
18321 {
18322
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.trigctr,f))
18323 return qe_invalid;
18324 9226 }
18325 else
18326 {
18327
1/2
✓ Branch 0 taken 7533 times.
✗ Branch 1 not taken.
7533 if(!p_getc(&tempbyte,f))
18328 return qe_invalid;
18329 7533 temp_trigger.trigctr = tempbyte;
18330 }
18331
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_igetl(&temp_trigger.trigctramnt,f))
18332 return qe_invalid;
18333
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_getc(&temp_trigger.triglbeam,f))
18334 return qe_invalid;
18335
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_getc(&temp_trigger.trigcschange,f))
18336 return qe_invalid;
18337
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_igetw(&temp_trigger.spawnitem,f))
18338 return qe_invalid;
18339
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_igetw(&temp_trigger.spawnenemy,f))
18340 return qe_invalid;
18341
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_getc(&temp_trigger.exstate,f))
18342 return qe_invalid;
18343
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_igetl(&temp_trigger.spawnip,f))
18344 return qe_invalid;
18345
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_getc(&temp_trigger.trigcopycat,f))
18346 return qe_invalid;
18347
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_getc(&temp_trigger.trigcooldown,f))
18348 return qe_invalid;
18349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16759 times.
16759 if(s_version >= 35)
18350 {
18351
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_igetw(&temp_trigger.prompt_cid,f))
18352 return qe_invalid;
18353
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_getc(&temp_trigger.prompt_cs,f))
18354 return qe_invalid;
18355
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_igetw(&temp_trigger.prompt_x,f))
18356 return qe_invalid;
18357
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(!p_igetw(&temp_trigger.prompt_y,f))
18358 return qe_invalid;
18359 16759 }
18360
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 16473 times.
16759 if(s_version >= 36)
18361 {
18362
1/2
✓ Branch 0 taken 16473 times.
✗ Branch 1 not taken.
16473 if(!p_getc(&temp_trigger.trig_lstate,f))
18363 return qe_invalid;
18364
1/2
✓ Branch 0 taken 16473 times.
✗ Branch 1 not taken.
16473 if(!p_getc(&temp_trigger.trig_gstate,f))
18365 return qe_invalid;
18366
1/2
✓ Branch 0 taken 16473 times.
✗ Branch 1 not taken.
16473 if(!p_igetl(&temp_trigger.trig_statetime,f))
18367 return qe_invalid;
18368 16473 }
18369
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 16473 times.
16759 if(s_version >= 37)
18370 {
18371
1/2
✓ Branch 0 taken 16473 times.
✗ Branch 1 not taken.
16473 if(!p_igetw(&temp_trigger.trig_genscr,f))
18372 return qe_invalid;
18373 16473 }
18374
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 16325 times.
16759 if(s_version >= 38)
18375 {
18376
1/2
✓ Branch 0 taken 16325 times.
✗ Branch 1 not taken.
16325 if(!p_getc(&temp_trigger.trig_group,f))
18377 return qe_invalid;
18378
1/2
✓ Branch 0 taken 16325 times.
✗ Branch 1 not taken.
16325 if(!p_igetw(&temp_trigger.trig_group_val,f))
18379 return qe_invalid;
18380 16325 }
18381
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 16289 times.
16759 if(s_version >= 45)
18382 {
18383
1/2
✓ Branch 0 taken 16289 times.
✗ Branch 1 not taken.
16289 if(!p_getc(&temp_trigger.exdoor_dir,f))
18384 return qe_invalid;
18385
1/2
✓ Branch 0 taken 16289 times.
✗ Branch 1 not taken.
16289 if(!p_getc(&temp_trigger.exdoor_ind,f))
18386 return qe_invalid;
18387 16289 }
18388
2/2
✓ Branch 0 taken 7533 times.
✓ Branch 1 taken 9226 times.
16759 if(s_version >= 46)
18389 {
18390
2/2
✓ Branch 0 taken 5920 times.
✓ Branch 1 taken 3306 times.
9226 if (s_version >= 59)
18391 {
18392
1/2
✓ Branch 0 taken 5920 times.
✗ Branch 1 not taken.
5920 if(!p_igetw(&temp_trigger.trig_levelitems,f))
18393 return qe_invalid;
18394 5920 }
18395 else
18396 {
18397
1/2
✓ Branch 0 taken 3306 times.
✗ Branch 1 not taken.
3306 if(!p_getc(&tempbyte,f))
18398 return qe_invalid;
18399 3306 temp_trigger.trig_levelitems = word(tempbyte);
18400 }
18401
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.trigdmlevel,f))
18402 return qe_invalid;
18403
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(s_version >= 48)
18404 {
18405
2/2
✓ Branch 0 taken 27678 times.
✓ Branch 1 taken 9226 times.
36904 for(int q = 0; q < 3; ++q)
18406
1/2
✓ Branch 0 taken 27678 times.
✗ Branch 1 not taken.
27678 if(!p_igetw(&temp_trigger.trigtint[q],f))
18407 return qe_invalid;
18408 9226 }
18409 else
18410 {
18411 for(int q = 0; q < 3; ++q)
18412 if(!p_getc(&temp_trigger.trigtint[q],f))
18413 return qe_invalid;
18414 for(int q = 0; q < 3; ++q)
18415 {
18416 int v = temp_trigger.trigtint[q];
18417 int va = abs(v);
18418 temp_trigger.trigtint[q] = _rgb_scale_6[va] * sign(v);
18419 }
18420 }
18421
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.triglvlpalette,f))
18422 return qe_invalid;
18423
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.trigbosspalette,f))
18424 return qe_invalid;
18425
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.trigquaketime,f))
18426 return qe_invalid;
18427
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.trigwavytime,f))
18428 return qe_invalid;
18429
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.trig_swjinxtime,f))
18430 return qe_invalid;
18431
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.trig_itmjinxtime,f))
18432 return qe_invalid;
18433
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.trig_stuntime,f))
18434 return qe_invalid;
18435
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.trig_bunnytime,f))
18436 return qe_invalid;
18437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9226 times.
9226 if(!p_getc(&temp_trigger.trig_pushtime,f))
18438 return qe_invalid;
18439 9226 }
18440
2/2
✓ Branch 0 taken 7533 times.
✓ Branch 1 taken 9226 times.
16759 if(s_version >= 47)
18441 {
18442
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if (!p_igetw(&temp_trigger.trig_shieldjinxtime, f))
18443 return qe_invalid;
18444 9226 }
18445
2/2
✓ Branch 0 taken 9226 times.
✓ Branch 1 taken 7533 times.
16759 if(s_version >= 53)
18446 {
18447
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetl(&temp_trigger.req_level_state, f))
18448 return qe_invalid;
18449
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetl(&temp_trigger.unreq_level_state, f))
18450 return qe_invalid;
18451
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_getbitstr(&temp_trigger.req_global_state, f))
18452 return qe_invalid;
18453
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_getbitstr(&temp_trigger.unreq_global_state, f))
18454 return qe_invalid;
18455
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetw(&temp_trigger.fail_prompt_cid,f))
18456 return qe_invalid;
18457
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_getc(&temp_trigger.fail_prompt_cs,f))
18458 return qe_invalid;
18459
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetl(&temp_trigger.trig_msgstr, f))
18460 return qe_invalid;
18461
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetl(&temp_trigger.fail_msgstr, f))
18462 return qe_invalid;
18463
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetzf(&temp_trigger.player_bounce, f))
18464 return qe_invalid;
18465
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if(!p_igetzf(&temp_trigger.req_player_z, f))
18466 return qe_invalid;
18467 9226 }
18468 else
18469 {
18470 7533 temp_trigger.fail_prompt_cid = temp_trigger.prompt_cid;
18471 7533 temp_trigger.fail_prompt_cs = temp_trigger.prompt_cs;
18472 }
18473
2/2
✓ Branch 0 taken 7779 times.
✓ Branch 1 taken 8980 times.
16759 if(s_version >= 54)
18474 {
18475
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_getc(&temp_trigger.req_player_dir,f))
18476 return qe_invalid;
18477
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_igetzf(&temp_trigger.dest_player_x, f))
18478 return qe_invalid;
18479
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_igetzf(&temp_trigger.dest_player_y, f))
18480 return qe_invalid;
18481
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_igetzf(&temp_trigger.dest_player_z, f))
18482 return qe_invalid;
18483
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_igetzf(&temp_trigger.req_player_jump, f))
18484 return qe_invalid;
18485
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_igetzf(&temp_trigger.req_player_x, f))
18486 return qe_invalid;
18487
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_igetzf(&temp_trigger.req_player_y, f))
18488 return qe_invalid;
18489 8980 }
18490
2/2
✓ Branch 0 taken 7779 times.
✓ Branch 1 taken 8980 times.
16759 if(s_version >= 56)
18491 {
18492
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_getc(&temp_trigger.dest_player_dir, f))
18493 return qe_invalid;
18494
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_igetl(&temp_trigger.force_ice_combo, f))
18495 return qe_invalid;
18496
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_igetzf(&temp_trigger.force_ice_vx, f))
18497 return qe_invalid;
18498
1/2
✓ Branch 0 taken 8980 times.
✗ Branch 1 not taken.
8980 if(!p_igetzf(&temp_trigger.force_ice_vy, f))
18499 return qe_invalid;
18500 8980 }
18501
2/2
✓ Branch 0 taken 10839 times.
✓ Branch 1 taken 5920 times.
16759 if(s_version >= 58)
18502 {
18503
1/2
✓ Branch 0 taken 5920 times.
✗ Branch 1 not taken.
5920 if(!p_igetzf(&temp_trigger.trig_gravity, f))
18504 return qe_invalid;
18505
1/2
✓ Branch 0 taken 5920 times.
✗ Branch 1 not taken.
5920 if(!p_igetzf(&temp_trigger.trig_terminal_v, f))
18506 return qe_invalid;
18507 5920 }
18508
2/2
✓ Branch 0 taken 11351 times.
✓ Branch 1 taken 5408 times.
16759 if (s_version >= 61)
18509 {
18510
1/2
✓ Branch 0 taken 5408 times.
✗ Branch 1 not taken.
5408 if(!p_getbitstr(&temp_trigger.req_screen_state, f))
18511 return qe_invalid;
18512
1/2
✓ Branch 0 taken 5408 times.
✗ Branch 1 not taken.
5408 if(!p_getbitstr(&temp_trigger.unreq_screen_state, f))
18513 return qe_invalid;
18514
1/2
✓ Branch 0 taken 5408 times.
✗ Branch 1 not taken.
5408 if(!p_getbitstr(&temp_trigger.req_screen_ex_state, f))
18515 return qe_invalid;
18516
1/2
✓ Branch 0 taken 5408 times.
✗ Branch 1 not taken.
5408 if(!p_getbitstr(&temp_trigger.unreq_screen_ex_state, f))
18517 return qe_invalid;
18518
1/2
✓ Branch 0 taken 5408 times.
✗ Branch 1 not taken.
5408 if(!p_getc(&temp_trigger.trigstatemap, f))
18519 return qe_invalid;
18520
1/2
✓ Branch 0 taken 5408 times.
✗ Branch 1 not taken.
5408 if(!p_getc(&temp_trigger.trigstatescreen, f))
18521 return qe_invalid;
18522 5408 }
18523
2/2
✓ Branch 0 taken 11752 times.
✓ Branch 1 taken 5007 times.
16759 if (s_version >= 62)
18524 {
18525
1/2
✓ Branch 0 taken 5007 times.
✗ Branch 1 not taken.
5007 if(!p_igetl(&temp_trigger.play_music, f))
18526 return qe_invalid;
18527
1/2
✓ Branch 0 taken 5007 times.
✗ Branch 1 not taken.
5007 if(!p_getc(&temp_trigger.set_music_refresh, f))
18528 return qe_invalid;
18529 5007 }
18530 16759 return 0;
18531 16759 }
18532
18533 1690804 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18534 {
18535 byte tempbyte;
18536 word tempword;
18537 word combo_has_flags;
18538
2/2
✓ Branch 0 taken 516098 times.
✓ Branch 1 taken 1174706 times.
1690804 if(s_version < 55)
18539 {
18540
1/2
✓ Branch 0 taken 516098 times.
✗ Branch 1 not taken.
516098 if(!p_getc(&tempbyte,f))
18541 return qe_invalid;
18542 516098 combo_has_flags = tempbyte;
18543 516098 }
18544 else
18545 {
18546
1/2
✓ Branch 0 taken 1174706 times.
✗ Branch 1 not taken.
1174706 if(!p_igetw(&combo_has_flags,f))
18547 return qe_invalid;
18548 }
18549
18550 1690804 temp_combo.clear();
18551
2/2
✓ Branch 0 taken 291243 times.
✓ Branch 1 taken 1399561 times.
1690804 if(combo_has_flags)
18552 {
18553
2/2
✓ Branch 0 taken 608483 times.
✓ Branch 1 taken 791078 times.
1399561 if(combo_has_flags&CHAS_BASIC)
18554 {
18555
1/2
✓ Branch 0 taken 791078 times.
✗ Branch 1 not taken.
791078 if(!p_igetl(&temp_combo.tile,f))
18556 return qe_invalid;
18557 791078 temp_combo.o_tile = temp_combo.tile;
18558
18559
1/2
✓ Branch 0 taken 791078 times.
✗ Branch 1 not taken.
791078 if(!p_getc(&temp_combo.flip,f))
18560 return qe_invalid;
18561
18562
1/2
✓ Branch 0 taken 791078 times.
✗ Branch 1 not taken.
791078 if(!p_getc(&temp_combo.walk,f))
18563 return qe_invalid;
18564
18565
1/2
✓ Branch 0 taken 791078 times.
✗ Branch 1 not taken.
791078 if(!p_getc(&temp_combo.type,f))
18566 return qe_invalid;
18567
18568
1/2
✓ Branch 0 taken 791078 times.
✗ Branch 1 not taken.
791078 if(!p_getc(&temp_combo.flag,f))
18569 return qe_invalid;
18570
18571
1/2
✓ Branch 0 taken 791078 times.
✗ Branch 1 not taken.
791078 if(!p_getc(&temp_combo.csets,f))
18572 return qe_invalid;
18573 791078 }
18574
2/2
✓ Branch 0 taken 1396013 times.
✓ Branch 1 taken 3548 times.
1399561 if(combo_has_flags&CHAS_SCRIPT)
18575 {
18576
2/2
✓ Branch 0 taken 3518 times.
✓ Branch 1 taken 30 times.
3548 if (s_version>=41)
18577 {
18578 3518 p_getcstr(&temp_combo.label, f);
18579 3518 }
18580 else
18581 {
18582 char label[12];
18583 30 label[11] = '\0';
18584
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
18585
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 if(!p_getc(&label[q],f))
18586 return qe_invalid;
18587 30 temp_combo.label = label;
18588 }
18589
18590
1/2
✓ Branch 0 taken 3548 times.
✗ Branch 1 not taken.
3548 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18591 3548 auto initd_count = s_version >= 43 ? 8 : 2;
18592
2/2
✓ Branch 0 taken 28204 times.
✓ Branch 1 taken 3548 times.
31752 for ( int32_t q = 0; q < initd_count; q++ )
18593
1/2
✓ Branch 0 taken 28204 times.
✗ Branch 1 not taken.
28204 if(!p_igetl(&temp_combo.initd[q],f))
18594 return qe_invalid;
18595 3548 }
18596
2/2
✓ Branch 0 taken 1214076 times.
✓ Branch 1 taken 185485 times.
1399561 if(combo_has_flags&CHAS_ANIM)
18597 {
18598
1/2
✓ Branch 0 taken 185485 times.
✗ Branch 1 not taken.
185485 if(!p_getc(&temp_combo.frames,f))
18599 return qe_invalid;
18600
18601
1/2
✓ Branch 0 taken 185485 times.
✗ Branch 1 not taken.
185485 if(!p_getc(&temp_combo.speed,f))
18602 return qe_invalid;
18603
18604
1/2
✓ Branch 0 taken 185485 times.
✗ Branch 1 not taken.
185485 if(!p_igetw(&temp_combo.nextcombo,f))
18605 return qe_invalid;
18606
18607
1/2
✓ Branch 0 taken 185485 times.
✗ Branch 1 not taken.
185485 if(!p_getc(&temp_combo.nextcset,f))
18608 return qe_invalid;
18609
18610
1/2
✓ Branch 0 taken 185485 times.
✗ Branch 1 not taken.
185485 if(!p_getc(&temp_combo.skipanim,f))
18611 return qe_invalid;
18612
18613
1/2
✓ Branch 0 taken 185485 times.
✗ Branch 1 not taken.
185485 if(!p_getc(&temp_combo.skipanimy,f))
18614 return qe_invalid;
18615
18616
1/2
✓ Branch 0 taken 185485 times.
✗ Branch 1 not taken.
185485 if(!p_getc(&temp_combo.animflags,f))
18617 return qe_invalid;
18618 185485 }
18619
2/2
✓ Branch 0 taken 1333747 times.
✓ Branch 1 taken 65814 times.
1399561 if(combo_has_flags&CHAS_ATTRIB)
18620 {
18621
2/2
✓ Branch 0 taken 26146 times.
✓ Branch 1 taken 39668 times.
65814 if (s_version < 63)
18622 {
18623
2/2
✓ Branch 0 taken 104584 times.
✓ Branch 1 taken 26146 times.
130730 for ( int32_t q = 0; q < 4; q++ )
18624
1/2
✓ Branch 0 taken 104584 times.
✗ Branch 1 not taken.
104584 if(!p_igetzf(&temp_combo.c_attributes[q],f))
18625 return qe_invalid;
18626
2/2
✓ Branch 0 taken 209168 times.
✓ Branch 1 taken 26146 times.
235314 for ( int32_t q = 0; q < 8; q++ )
18627 {
18628
1/2
✓ Branch 0 taken 209168 times.
✗ Branch 1 not taken.
209168 if(!p_getc(&tempbyte,f))
18629 return qe_invalid;
18630 209168 temp_combo.c_attributes[8 + q] = tempbyte;
18631 209168 }
18632
2/2
✓ Branch 0 taken 209168 times.
✓ Branch 1 taken 26146 times.
235314 for ( int32_t q = 0; q < 8; q++ )
18633 {
18634
1/2
✓ Branch 0 taken 209168 times.
✗ Branch 1 not taken.
209168 if(!p_igetw(&tempword,f))
18635 return qe_invalid;
18636 209168 temp_combo.c_attributes[16 + q] = int16_t(tempword);
18637 209168 }
18638 26146 }
18639 else
18640 {
18641 word num_attributes;
18642
1/2
✓ Branch 0 taken 39668 times.
✗ Branch 1 not taken.
39668 if (!p_igetw(&num_attributes, f))
18643 return qe_invalid;
18644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39668 times.
39668 if (num_attributes > NUM_COMBO_ATTRIBUTES)
18645 return qe_invalid;
18646
2/2
✓ Branch 0 taken 952032 times.
✓ Branch 1 taken 39668 times.
991700 for (size_t q = 0; q < num_attributes; ++q)
18647 {
18648
1/2
✓ Branch 0 taken 952032 times.
✗ Branch 1 not taken.
952032 if (!p_igetzf(&temp_combo.c_attributes[q],f))
18649 return qe_invalid;
18650 952032 }
18651 }
18652 65814 }
18653
2/2
✓ Branch 0 taken 1383177 times.
✓ Branch 1 taken 16384 times.
1399561 if(combo_has_flags&CHAS_FLAG)
18654 {
18655
1/2
✓ Branch 0 taken 16384 times.
✗ Branch 1 not taken.
16384 if(!p_igetl(&temp_combo.usrflags,f))
18656 return qe_invalid;
18657
1/2
✓ Branch 0 taken 16384 times.
✗ Branch 1 not taken.
16384 if(!p_igetw(&temp_combo.genflags,f))
18658 return qe_invalid;
18659 16384 }
18660
2/2
✓ Branch 0 taken 1382920 times.
✓ Branch 1 taken 16641 times.
1399561 if(combo_has_flags&CHAS_TRIG)
18661 {
18662 16641 byte count = 1;
18663
2/2
✓ Branch 0 taken 7533 times.
✓ Branch 1 taken 9108 times.
16641 if(s_version >= 52)
18664
1/2
✓ Branch 0 taken 9108 times.
✗ Branch 1 not taken.
9108 if(!p_getc(&count, f))
18665 return qe_invalid;
18666
18667
2/2
✓ Branch 0 taken 16759 times.
✓ Branch 1 taken 16641 times.
33400 for(byte q = 0; q < count; ++q)
18668 {
18669 16759 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
18670 16759 auto ret = readcombo_triggers_loop(f, s_version, temp_trigger);
18671
1/2
✓ Branch 0 taken 16759 times.
✗ Branch 1 not taken.
16759 if(ret)
18672 return ret;
18673 16759 }
18674
18675
2/2
✓ Branch 0 taken 7533 times.
✓ Branch 1 taken 9108 times.
16641 if(s_version < 52)
18676 {
18677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7533 times.
7533 if(!temp_combo.triggers.empty())
18678 7533 temp_combo.only_gentrig = (temp_combo.triggers[0].trigger_flags.get(TRIGFLAG_ONLYGENTRIG)) ? 1 : 0;
18679 7533 }
18680
1/2
✓ Branch 0 taken 9108 times.
✗ Branch 1 not taken.
9108 else if(!p_getc(&temp_combo.only_gentrig,f))
18681 return qe_invalid;
18682 16641 }
18683
2/2
✓ Branch 0 taken 224729 times.
✓ Branch 1 taken 1174832 times.
1399561 if(combo_has_flags&CHAS_LIFT)
18684 {
18685
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_igetw(&temp_combo.liftcmb,f))
18686 return qe_invalid;
18687
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftcs,f))
18688 return qe_invalid;
18689
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_igetw(&temp_combo.liftundercmb,f))
18690 return qe_invalid;
18691
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftundercs,f))
18692 return qe_invalid;
18693
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftdmg,f))
18694 return qe_invalid;
18695
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftlvl,f))
18696 return qe_invalid;
18697
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftitm,f))
18698 return qe_invalid;
18699
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftflags,f))
18700 return qe_invalid;
18701
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftgfx,f))
18702 return qe_invalid;
18703
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftsprite,f))
18704 return qe_invalid;
18705
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftsfx,f))
18706 return qe_invalid;
18707
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18708 return qe_invalid;
18709
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.liftbreaksfx,f))
18710 return qe_invalid;
18711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1174832 times.
1174832 if(s_version >= 34)
18712 {
18713
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.lifthei,f))
18714 return qe_invalid;
18715
1/2
✓ Branch 0 taken 1174832 times.
✗ Branch 1 not taken.
1174832 if(!p_getc(&temp_combo.lifttime,f))
18716 return qe_invalid;
18717 1174832 }
18718
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1174818 times.
1174832 if(s_version >= 39)
18719 {
18720
1/2
✓ Branch 0 taken 1174818 times.
✗ Branch 1 not taken.
1174818 if(!p_getc(&temp_combo.lift_parent_item,f))
18721 return qe_invalid;
18722 1174818 }
18723 1174832 auto& weap_data = temp_combo.lift_weap_data;
18724
4/4
✓ Branch 0 taken 1174730 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 1174706 times.
✓ Branch 3 taken 24 times.
1174832 if(s_version >= 51 && s_version < 55)
18725 {
18726
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.light_rads[WPNSPR_BASE],f))
18727 return qe_invalid;
18728
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.glow_shape,f))
18729 return qe_invalid;
18730 24 }
18731
18732
2/2
✓ Branch 0 taken 1174706 times.
✓ Branch 1 taken 126 times.
1174832 if(s_version >= 55)
18733 {
18734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1174706 times.
1174706 if(auto ret = read_weap_data(weap_data, f))
18735 return ret;
18736 1174706 }
18737 else
18738 {
18739 126 auto const& pitm = itemsbuf[temp_combo.lift_parent_item];
18740 126 auto weap_glow = weap_data.light_rads[WPNSPR_BASE];
18741
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 120 times.
126 switch(pitm.type)
18742 {
18743 case itype_bomb:
18744 case itype_sbomb:
18745 6 weap_data = pitm.weap_data;
18746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!(weap_data.wflags & WFLAG_UPDATE_IGNITE_SPRITE))
18747 {
18748 6 weap_data.flags |= wdata_glow_rad;
18749 6 weap_data.light_rads[WPNSPR_BASE] = weap_glow;
18750 6 }
18751 6 break;
18752 default:
18753 120 weap_data.wflags |= WFLAG_BREAK_WHEN_LANDING;
18754 120 weap_data.flags |= wdata_glow_rad;
18755 120 }
18756 126 weap_data.moveflags |= move_obeys_grav|move_can_pitfall;
18757
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 66 times.
126 if(temp_combo.liftflags & LF_BREAKONSOLID)
18758 60 weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
18759 }
18760 1174832 }
18761
18762
2/2
✓ Branch 0 taken 1362941 times.
✓ Branch 1 taken 36620 times.
1399561 if(combo_has_flags&CHAS_GENERAL)
18763 {
18764
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.speed_mult,f))
18765 return qe_invalid;
18766
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.speed_div,f))
18767 return qe_invalid;
18768
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_igetzf(&temp_combo.speed_add,f))
18769 return qe_invalid;
18770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36620 times.
36620 if(s_version >= 42)
18771 {
18772
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_appear,f))
18773 return qe_invalid;
18774
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_disappear,f))
18775 return qe_invalid;
18776
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_loop,f))
18777 return qe_invalid;
18778
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_walking,f))
18779 return qe_invalid;
18780
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_standing,f))
18781 return qe_invalid;
18782
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.spr_appear,f))
18783 return qe_invalid;
18784
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.spr_disappear,f))
18785 return qe_invalid;
18786
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.spr_walking,f))
18787 return qe_invalid;
18788
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.spr_standing,f))
18789 return qe_invalid;
18790 36620 }
18791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36620 times.
36620 if(s_version >= 44)
18792 {
18793
1/2
✓ Branch 0 taken 36620 times.
✗ Branch 1 not taken.
36620 if(!p_getc(&temp_combo.sfx_tap,f))
18794 return qe_invalid;
18795 36620 }
18796
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 36236 times.
36620 if(s_version >= 49)
18797 {
18798
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.sfx_landing,f))
18799 return qe_invalid;
18800 36236 }
18801
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 36236 times.
36620 if(s_version >= 50)
18802 {
18803
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.spr_falling,f))
18804 return qe_invalid;
18805
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.spr_drowning,f))
18806 return qe_invalid;
18807
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18808 return qe_invalid;
18809
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.sfx_falling,f))
18810 return qe_invalid;
18811
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.sfx_drowning,f))
18812 return qe_invalid;
18813
1/2
✓ Branch 0 taken 36236 times.
✗ Branch 1 not taken.
36236 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18814 return qe_invalid;
18815 36236 }
18816
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 34742 times.
36620 if(s_version >= 56)
18817 {
18818
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_igetzf(&temp_combo.z_height,f))
18819 return qe_invalid;
18820
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_igetzf(&temp_combo.z_step_height,f))
18821 return qe_invalid;
18822 34742 }
18823
2/2
✓ Branch 0 taken 3208 times.
✓ Branch 1 taken 33412 times.
36620 if(s_version >= 60)
18824 {
18825
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.dive_under_level,f))
18826 return qe_invalid;
18827 33412 }
18828 36620 }
18829
2/2
✓ Branch 0 taken 1399558 times.
✓ Branch 1 taken 3 times.
1399561 if(combo_has_flags&CHAS_MISC_WEAP_DATA)
18830 {
18831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(auto ret = read_weap_data(temp_combo.misc_weap_data, f))
18832 return ret;
18833 3 }
18834 1399561 }
18835 1690804 update_combo(temp_combo, s_version);
18836 1690804 return 0;
18837 1690804 }
18838
18839 498 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18840 {
18841
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18842
18843 498 word section_version=0;
18844 498 word combos_used=0;
18845 int32_t dummy;
18846 byte padding;
18847 498 newcombo temp_combo;
18848
18849
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 497 times.
498 if (!should_skip)
18850 {
18851
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 reset_all_combo_animations();
18852
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 init_combo_classes();
18853
18854
2/2
✓ Branch 0 taken 32444160 times.
✓ Branch 1 taken 497 times.
32444657 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18855
1/2
✓ Branch 0 taken 32444160 times.
✗ Branch 1 not taken.
32444160 combobuf[q].clear();
18856 497 }
18857
18858
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 24 times.
498 if(version > 0x192) //Version info
18859 {
18860
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&section_version,f))
18861 {
18862 return qe_invalid;
18863 }
18864 474 FFCore.quest_format[vCombos] = section_version;
18865
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!read_deprecated_section_cversion(f))
18866 {
18867 return qe_invalid;
18868 }
18869
18870 //section size
18871
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&dummy,f))
18872 {
18873 return qe_invalid;
18874 }
18875 474 }
18876
18877
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 288 times.
498 if(section_version > 32) //Cleanup time!
18878 {
18879
2/4
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
210 if(!p_igetw(&combos_used,f))
18880 {
18881 return qe_invalid;
18882 }
18883
2/2
✓ Branch 0 taken 1690804 times.
✓ Branch 1 taken 210 times.
1691014 for(int32_t i=0; i<combos_used; i++)
18884 {
18885
1/2
✓ Branch 0 taken 1690804 times.
✗ Branch 1 not taken.
1690804 auto ret = readcombo_loop(f,section_version,temp_combo);
18886
1/2
✓ Branch 0 taken 1690804 times.
✗ Branch 1 not taken.
1690804 if(ret) return ret;
18887
1/2
✓ Branch 0 taken 1690804 times.
✗ Branch 1 not taken.
1690804 if(i>=start_combo)
18888 {
18889
1/2
✓ Branch 0 taken 1690804 times.
✗ Branch 1 not taken.
1690804 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18890 {
18891 temp_combo.script = 0;
18892 for(int q = 0; q < 8; ++q)
18893 temp_combo.initd[q] = 0;
18894 }
18895
1/2
✓ Branch 0 taken 1690804 times.
✗ Branch 1 not taken.
1690804 combobuf[i] = temp_combo;
18896 1690804 }
18897 1690804 }
18898 210 }
18899 else //Call the old function for all old versions
18900 {
18901
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(ret) return ret; //error, end read
18903 }
18904
18905
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 1 times.
498 if (should_skip)
18906 1 return 0;
18907
18908
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 201 times.
497 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18909 {
18910 201 combobuf[0].walk = 0xF0;
18911 201 combobuf[0].type = 0;
18912 201 combobuf[0].flag = 0;
18913 201 }
18914
18915
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 setup_combo_animations();
18916
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 setup_combo_animations2();
18917 497 return 0;
18918 498 }
18919
18920 415 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18921 {
18922 //these are here to bypass compiler warnings about unused arguments
18923 415 Header=Header;
18924 415 version=version;
18925 415 build=build;
18926
18927 int32_t dummy;
18928 415 word sversion=0, c_sversion;
18929
18930 //section version info
18931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(!p_igetw(&sversion,f))
18932 {
18933 return qe_invalid;
18934 }
18935
18936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (sversion > V_COMBOALIASES)
18937 return qe_version;
18938
18939 415 FFCore.quest_format[vComboAliases] = sversion;
18940
18941
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetw(&c_sversion,f))
18942 {
18943 return qe_invalid;
18944 }
18945
18946 //section size
18947
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy,f))
18948 {
18949 return qe_invalid;
18950 }
18951
18952 415 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18953
18954
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 200 times.
415 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18955 {
18956 200 max_num_combo_aliases = MAX250COMBOALIASES;
18957 200 }
18958
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18959 {
18960 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18961 }
18962
18963
2/2
✓ Branch 0 taken 2170880 times.
✓ Branch 1 taken 415 times.
2171295 for(int32_t j=0; j<max_num_combo_aliases; j++)
18964 {
18965 byte width,height,mask,tempcset;
18966 int32_t count;
18967 word tempword;
18968 byte tempbyte;
18969
18970
1/2
✓ Branch 0 taken 2170880 times.
✗ Branch 1 not taken.
2170880 if(!p_igetw(&tempword,f))
18971 {
18972 return qe_invalid;
18973 }
18974
18975 2170880 combo_aliases[j].combo = tempword;
18976
18977
1/2
✓ Branch 0 taken 2170880 times.
✗ Branch 1 not taken.
2170880 if(!p_getc(&tempbyte,f))
18978 {
18979 return qe_invalid;
18980 }
18981
18982 2170880 combo_aliases[j].cset = tempbyte;
18983
18984
1/2
✓ Branch 0 taken 2170880 times.
✗ Branch 1 not taken.
2170880 if(!p_getc(&width,f))
18985 {
18986 return qe_invalid;
18987 }
18988
18989
1/2
✓ Branch 0 taken 2170880 times.
✗ Branch 1 not taken.
2170880 if(!p_getc(&height,f))
18990 {
18991 return qe_invalid;
18992 }
18993
18994
1/2
✓ Branch 0 taken 2170880 times.
✗ Branch 1 not taken.
2170880 if(!p_getc(&mask,f))
18995 {
18996 return qe_invalid;
18997 }
18998
18999 2170880 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
19000
19001 2170880 combo_aliases[j].width = width;
19002 2170880 combo_aliases[j].height = height;
19003 2170880 combo_aliases[j].layermask = mask;
19004 2170880 combo_aliases[j].combos.clear();
19005 2170880 combo_aliases[j].csets.clear();
19006
19007
2/2
✓ Branch 0 taken 2229109 times.
✓ Branch 1 taken 2170880 times.
4399989 for(int32_t k=0; k<count; k++)
19008 {
19009
1/2
✓ Branch 0 taken 2229109 times.
✗ Branch 1 not taken.
2229109 if(!p_igetw(&tempword,f))
19010 {
19011 return qe_invalid;
19012 }
19013
19014 2229109 combo_aliases[j].combos[k] = tempword;
19015 2229109 }
19016
19017
2/2
✓ Branch 0 taken 2229109 times.
✓ Branch 1 taken 2170880 times.
4399989 for(int32_t k=0; k<count; k++)
19018 {
19019
1/2
✓ Branch 0 taken 2229109 times.
✗ Branch 1 not taken.
2229109 if(!p_getc(&tempcset,f))
19020 {
19021 return qe_invalid;
19022 }
19023
19024 2229109 combo_aliases[j].csets[k] = tempcset;
19025 2229109 }
19026 2170880 }
19027
19028 //Combo pools!
19029 415 word num_combo_pools = 0;
19030
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 210 times.
415 if(sversion >= 4)
19031 {
19032
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(!p_igetw(&num_combo_pools,f))
19033 {
19034 return qe_invalid;
19035 }
19036 210 }
19037
19038
2/2
✓ Branch 0 taken 3399680 times.
✓ Branch 1 taken 415 times.
3400095 for(combo_pool& pool : combo_pools)
19039 {
19040 3399680 pool.clear();
19041 }
19042
19043 415 combo_pool temp_cpool;
19044
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 415 times.
1123 for(word cp = 0; cp < num_combo_pools; ++cp)
19045 {
19046 708 int32_t num_combos_in_pool = 0;
19047
2/4
✓ Branch 0 taken 708 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 708 times.
✗ Branch 3 not taken.
708 if(!p_igetl(&num_combos_in_pool,f))
19048 {
19049 return qe_invalid;
19050 }
19051
2/2
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 106 times.
708 if(num_combos_in_pool < 1) continue; //nothing to read
19052
19053
1/2
✓ Branch 0 taken 602 times.
✗ Branch 1 not taken.
602 temp_cpool.clear();
19054
19055 int32_t cp_cid; int8_t cp_cs; word cp_quant;
19056
2/2
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 2753 times.
3355 for(auto q = 0; q < num_combos_in_pool; ++q)
19057 {
19058
2/4
✓ Branch 0 taken 2753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2753 times.
✗ Branch 3 not taken.
2753 if(!p_igetl(&cp_cid,f))
19059 {
19060 return qe_invalid;
19061 }
19062
2/4
✓ Branch 0 taken 2753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2753 times.
✗ Branch 3 not taken.
2753 if(!p_getc(&cp_cs,f))
19063 {
19064 return qe_invalid;
19065 }
19066
2/4
✓ Branch 0 taken 2753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2753 times.
✗ Branch 3 not taken.
2753 if(!p_igetw(&cp_quant,f))
19067 {
19068 return qe_invalid;
19069 }
19070
1/2
✓ Branch 0 taken 2753 times.
✗ Branch 1 not taken.
2753 temp_cpool.add(cp_cid, cp_cs, cp_quant);
19071 2753 }
19072
19073
1/2
✓ Branch 0 taken 602 times.
✗ Branch 1 not taken.
602 combo_pools[cp] = temp_cpool;
19074 602 }
19075
19076 //Autocombos!
19077 415 word num_combo_autos = 0;
19078
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 217 times.
415 if (sversion >= 5)
19079 {
19080
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if (!p_igetw(&num_combo_autos, f))
19081 {
19082 return qe_invalid;
19083 }
19084 198 }
19085
19086
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 3399680 times.
3400095 for (combo_auto& cauto : combo_autos)
19087 {
19088
1/2
✓ Branch 0 taken 3399680 times.
✗ Branch 1 not taken.
3399680 cauto.clear(true);
19089 }
19090
19091
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 combo_auto temp_cauto;
19092
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 415 times.
569 for (word ca = 0; ca < num_combo_autos; ++ca)
19093 {
19094 byte type;
19095 int32_t display_cid, erase_cid;
19096 byte flags, arg;
19097
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_getc(&type, f))
19098 {
19099 return qe_invalid;
19100 }
19101
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_igetl(&display_cid, f))
19102 {
19103 return qe_invalid;
19104 }
19105
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_igetl(&erase_cid, f))
19106 {
19107 return qe_invalid;
19108 }
19109
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_getc(&flags, f))
19110 {
19111 return qe_invalid;
19112 }
19113
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_getc(&arg, f))
19114 {
19115 return qe_invalid;
19116 }
19117 154 int32_t num_combos_in_cauto = 0;
19118
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if (!p_igetl(&num_combos_in_cauto, f))
19119 {
19120 return qe_invalid;
19121 }
19122
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 21 times.
154 if (num_combos_in_cauto < 1) continue; //nothing to read
19123
19124
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.clear();
19125
19126
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.setType(type);
19127
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.setDisplay(display_cid);
19128
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.setEraseCombo(erase_cid);
19129
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.setFlags(flags);
19130
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 temp_cauto.setArg(arg);
19131
19132 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
19133
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 3389 times.
3522 for (auto q = 0; q < num_combos_in_cauto; ++q)
19134 {
19135
2/4
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3389 times.
✗ Branch 3 not taken.
3389 if (!p_getc(&ca_ctype, f))
19136 {
19137 return qe_invalid;
19138 }
19139
2/4
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3389 times.
✗ Branch 3 not taken.
3389 if (!p_igetl(&ca_cid, f))
19140 {
19141 return qe_invalid;
19142 }
19143
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
19144 3389 }
19145
19146
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 combo_autos[ca] = temp_cauto;
19147 133 }
19148
19149 415 return 0;
19150 415 }
19151
19152 832 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
19153 {
19154
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
19155
19156 //these are here to bypass compiler warnings about unused arguments
19157 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
19158 //Capitalized cause it'll save you a headache. -Deedee
19159 832 start_cset=start_cset;
19160 832 max_csets=max_csets;
19161 832 word s_version=0;
19162
19163 832 miscQdata temp_misc;
19164
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 temp_misc = *Misc;
19165
19166 byte temp_colordata[48];
19167 char temp_palname[PALNAMESIZE+1];
19168
19169 int32_t dummy;
19170 word palcycles;
19171
19172
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(version > 0x192)
19173 {
19174 //section version info
19175
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&s_version,f))
19176 {
19177 return qe_invalid;
19178 }
19179
19180
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if (s_version > V_CSETS)
19181 return qe_version;
19182
19183 808 FFCore.quest_format[vCSets] = s_version;
19184
19185
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&dummy,f))
19186 {
19187 return qe_invalid;
19188 }
19189
19190 //section size
19191
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetl(&dummy,f))
19192 {
19193 return qe_invalid;
19194 }
19195 808 }
19196
2/2
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 215 times.
832 if (s_version < 5)
19197 {
19198
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 599 times.
✓ Branch 2 taken 593 times.
✓ Branch 3 taken 6 times.
617 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
19199
19200 //finally... section data
19201 617 int32_t q = 0;
19202 617 int32_t p = -15;
19203
2/2
✓ Branch 0 taken 148080 times.
✓ Branch 1 taken 617 times.
148697 for(int32_t i=0; i<oldpdTOTAL; ++i)
19204 {
19205 148080 memset(temp_colordata, 0, 48);
19206
19207
2/4
✓ Branch 0 taken 148080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148080 times.
✗ Branch 3 not taken.
148080 if(!pfread(temp_colordata,48,f))
19208 {
19209 return qe_invalid;
19210 }
19211
19212
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 147840 times.
148080 if (should_skip)
19213 240 continue;
19214
19215 147840 memcpy(&colordata[q*48], temp_colordata, 48);
19216
19217 147840 ++q;
19218
8/8
✓ Branch 0 taken 137984 times.
✓ Branch 1 taken 9856 times.
✓ Branch 2 taken 10472 times.
✓ Branch 3 taken 127512 times.
✓ Branch 4 taken 1232 times.
✓ Branch 5 taken 9240 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1196 times.
147840 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
19219 {
19220
1/2
✓ Branch 0 taken 10436 times.
✗ Branch 1 not taken.
10436 if (s_version < 5) //Bumping up the size of level palettes
19221 {
19222 10436 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19223 10436 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19224 10436 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19225 10436 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19226 10436 q+=4;
19227 10436 }
19228 else
19229 {
19230 for(int m = 0; m < 4; ++m)
19231 {
19232 memset(temp_colordata, 0, 48);
19233 if(!pfread(temp_colordata,48,f))
19234 {
19235 return qe_invalid;
19236 }
19237 memcpy(&colordata[q*48], temp_colordata, 48);
19238 ++q;
19239 }
19240 }
19241 10436 }
19242 147840 ++p;
19243 147840 }
19244
19245
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 599 times.
617 if(RealOldVerion)
19246 {
19247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19248 {
19249 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19250 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19251 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
19252 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
19253 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
19254 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
19255 18 }
19256 18 }
19257 else
19258 {
19259 599 memset(temp_colordata, 0, 48);
19260
19261
2/2
✓ Branch 0 taken 1876667 times.
✓ Branch 1 taken 599 times.
1877266 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
19262 {
19263
2/4
✓ Branch 0 taken 1876667 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1876667 times.
✗ Branch 3 not taken.
1876667 if(!pfread(temp_colordata,48,f))
19264 {
19265 return qe_invalid;
19266 }
19267
19268
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1873534 times.
1876667 if (should_skip)
19269 3133 continue;
19270
19271 1873534 memcpy(&colordata[q*48], temp_colordata, 48);
19272
19273 1873534 ++q;
19274
7/8
✓ Branch 0 taken 1873534 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144118 times.
✓ Branch 3 taken 1729416 times.
✓ Branch 4 taken 1196 times.
✓ Branch 5 taken 142922 times.
✓ Branch 6 taken 1068 times.
✓ Branch 7 taken 128 times.
1873534 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
19275 {
19276
1/2
✓ Branch 0 taken 143990 times.
✗ Branch 1 not taken.
143990 if (s_version < 5) //Bumping up the size of level palettes
19277 {
19278 143990 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19279 143990 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19280 143990 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19281 143990 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19282 143990 q+=4;
19283 143990 }
19284 else
19285 {
19286 for(int m = 0; m < 4; ++m)
19287 {
19288 memset(temp_colordata, 0, 48);
19289 if(!pfread(temp_colordata,48,f))
19290 {
19291 return qe_invalid;
19292 }
19293 memcpy(&colordata[q*48], temp_colordata, 48);
19294 ++q;
19295 }
19296 }
19297 143990 }
19298 1873534 ++p;
19299 1873534 }
19300
19301
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 534 times.
599 if(s_version < 4)
19302 {
19303
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
19304 {
19305 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19306 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19307 64 }
19308 65 }
19309 else
19310 {
19311
2/2
✓ Branch 0 taken 1777152 times.
✓ Branch 1 taken 534 times.
1777686 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
19312 {
19313
2/4
✓ Branch 0 taken 1777152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1777152 times.
✗ Branch 3 not taken.
1777152 if(!pfread(temp_colordata,48,f))
19314 {
19315 return qe_invalid;
19316 }
19317
19318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1777152 times.
1777152 if (should_skip)
19319 continue;
19320
19321 1777152 memcpy(&colordata[q*48], temp_colordata, 48);
19322 1777152 ++q;
19323
5/6
✓ Branch 0 taken 1777152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136704 times.
✓ Branch 3 taken 1640448 times.
✓ Branch 4 taken 1068 times.
✓ Branch 5 taken 135636 times.
1777152 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
19324 {
19325
1/2
✓ Branch 0 taken 135636 times.
✗ Branch 1 not taken.
135636 if (s_version < 5) //Bumping up the size of level palettes
19326 {
19327 135636 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19328 135636 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19329 135636 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19330 135636 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19331 135636 q+=4;
19332 135636 }
19333 else
19334 {
19335 for(int m = 0; m < 4; ++m)
19336 {
19337 memset(temp_colordata, 0, 48);
19338 if(!pfread(temp_colordata,48,f))
19339 {
19340 return qe_invalid;
19341 }
19342 memcpy(&colordata[q*48], temp_colordata, 48);
19343 ++q;
19344 }
19345 }
19346 135636 }
19347 1777152 ++p;
19348 1777152 }
19349
19350 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19351 }
19352 }
19353 617 }
19354 else
19355 {
19356
2/2
✓ Branch 0 taken 1881035 times.
✓ Branch 1 taken 215 times.
1881250 for(int32_t i=0; i<pdTOTAL255; ++i)
19357 {
19358 1881035 memset(temp_colordata, 0, 48);
19359
19360
2/4
✓ Branch 0 taken 1881035 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1881035 times.
✗ Branch 3 not taken.
1881035 if(!pfread(temp_colordata,48,f))
19361 {
19362 return qe_invalid;
19363 }
19364
19365 1881035 memcpy(&colordata[i*48], temp_colordata, 48);
19366 1881035 }
19367 }
19368
19369
4/4
✓ Branch 0 taken 831 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 169 times.
✓ Branch 3 taken 662 times.
832 if (!should_skip && s_version < 6)
19370 {
19371
2/2
✓ Branch 0 taken 278008224 times.
✓ Branch 1 taken 662 times.
278008886 for (int i = 0; i < psTOTAL255; i++)
19372 {
19373 278008224 colordata[i] = _rgb_scale_6[colordata[i]];
19374 278008224 }
19375 662 }
19376
19377
5/6
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 808 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
832 if((version < 0x192)||((version == 0x192)&&(build<76)))
19378 {
19379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19380 18 init_palnames();
19381 18 }
19382 else
19383 {
19384 814 int32_t palnamestoread = 0;
19385
19386
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 749 times.
814 if(s_version < 3)
19387 65 palnamestoread = OLDMAXLEVELS;
19388 else
19389 749 palnamestoread = 512;
19390
19391
2/2
✓ Branch 0 taken 400128 times.
✓ Branch 1 taken 814 times.
400942 for(int32_t i=0; i<palnamestoread; ++i)
19392 {
19393
2/4
✓ Branch 0 taken 400128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 400128 times.
✗ Branch 3 not taken.
400128 if(!p_getstr(temp_palname,PALNAMESIZE,f))
19394 {
19395 return qe_invalid;
19396 }
19397
19398
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 399872 times.
400128 if (!should_skip)
19399 399872 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19400 400128 }
19401
19402
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 813 times.
814 if (should_skip)
19403 1 return 0;
19404
19405
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 813 times.
17197 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19406 {
19407 16384 memset(palnames[i], 0, PALNAMESIZE);
19408 16384 }
19409 }
19410
19411
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 808 times.
831 if(version > 0x192)
19412 {
19413
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 206848 times.
207656 for(int32_t i=0; i<256; i++)
19414 {
19415
2/2
✓ Branch 0 taken 620544 times.
✓ Branch 1 taken 206848 times.
827392 for(int32_t j=0; j<3; j++)
19416 {
19417 620544 temp_misc.cycles[i][j].first=0;
19418 620544 temp_misc.cycles[i][j].count=0;
19419 620544 temp_misc.cycles[i][j].speed=0;
19420 620544 }
19421 206848 }
19422
19423
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_igetw(&palcycles,f))
19424 {
19425 return qe_invalid;
19426 }
19427
19428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if (palcycles > NUM_PAL_CYCLES)
19429 {
19430 return qe_invalid;
19431 }
19432
19433
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 22465 times.
23273 for(int32_t i=0; i<palcycles; i++)
19434 {
19435
2/2
✓ Branch 0 taken 67395 times.
✓ Branch 1 taken 22465 times.
89860 for(int32_t j=0; j<3; j++)
19436 {
19437
2/4
✓ Branch 0 taken 67395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67395 times.
✗ Branch 3 not taken.
67395 if(!p_getc(&temp_misc.cycles[i][j].first,f))
19438 {
19439 return qe_invalid;
19440 }
19441 67395 }
19442
19443
2/2
✓ Branch 0 taken 67395 times.
✓ Branch 1 taken 22465 times.
89860 for(int32_t j=0; j<3; j++)
19444 {
19445
2/4
✓ Branch 0 taken 67395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67395 times.
✗ Branch 3 not taken.
67395 if(!p_getc(&temp_misc.cycles[i][j].count,f))
19446 {
19447 return qe_invalid;
19448 }
19449 67395 }
19450
19451
2/2
✓ Branch 0 taken 67395 times.
✓ Branch 1 taken 22465 times.
89860 for(int32_t j=0; j<3; j++)
19452 {
19453
2/4
✓ Branch 0 taken 67395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67395 times.
✗ Branch 3 not taken.
67395 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
19454 {
19455 return qe_invalid;
19456 }
19457 67395 }
19458 22465 }
19459
19460
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 *Misc = temp_misc;
19461 808 }
19462
19463 831 return 0;
19464 832 }
19465
19466 832 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
19467 {
19468
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
19469
19470 832 int32_t tiles_used=0;
19471 832 word section_version = 0;
19472 832 int32_t section_size= 0;
19473 832 byte *temp_tile = new byte[tilesize(tf32Bit)];
19474
19475 //Tile Expansion
19476 //if ( version >= 0x254 && build >= 41 )
19477
4/4
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 215 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 611 times.
832 if (version < 0x254 && build < 41)
19478 {
19479 611 max_tiles = ZC250MAXTILES;
19480 611 }
19481
19482
19483
2/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 832 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19484 {
19485 if(!init_tiles_for_190(true, Header))
19486 {
19487 al_trace("Unable to initialize tiles\n");
19488 }
19489
19490 delete[] temp_tile;
19491 temp_tile=NULL;
19492 return 0;
19493 }
19494 else
19495 {
19496
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 808 times.
832 if(version > 0x192)
19497 {
19498 //section version info
19499
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_igetw(&section_version,f))
19500 {
19501 delete[] temp_tile;
19502 return qe_invalid;
19503 }
19504
19505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if (section_version > V_TILES)
19506 return qe_version;
19507
19508 808 FFCore.quest_format[vTiles] = section_version;
19509
19510
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!read_deprecated_section_cversion(f))
19511 {
19512 delete[] temp_tile;
19513 return qe_invalid;
19514 }
19515
19516 //section size
19517
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_igetl(&section_size,f))
19518 {
19519 delete[] temp_tile;
19520 return qe_invalid;
19521 }
19522 808 }
19523
19524 //if ( build < 41 )
19525 //{
19526 // tiles_used = ZC250MAXTILES;
19527 //}
19528
19529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(version < 0x174)
19530 {
19531 tiles_used=TILES_PER_PAGE*4;
19532 } //no expanded tile space
19533
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 814 times.
832 else if(version < 0x191)
19534 {
19535 18 tiles_used=OLDMAXTILES;
19536 18 }
19537 else
19538 {
19539 //finally... section data
19540
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 599 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
814 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19541 {
19542
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 if(!p_igetl(&tiles_used,f))
19543 {
19544 delete[] temp_tile;
19545 return qe_invalid;
19546 }
19547 215 }
19548 else
19549 {
19550
1/2
✓ Branch 0 taken 599 times.
✗ Branch 1 not taken.
599 if(!p_igetw(&tiles_used,f))
19551 {
19552 delete[] temp_tile;
19553 return qe_invalid;
19554 }
19555 }
19556 }
19557
19558
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 tiles_used=zc_min(tiles_used, max_tiles);
19559
19560 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19561 //if ( version < 0x254 && build < 41 )
19562
3/6
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 617 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if ( version < 0x254 || (version == 0x254 && build < 41) )
19563 //if ( build < 41 )
19564 {
19565
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19566 617 }
19567 else //2.55
19568 {
19569
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19570 }
19571
19572 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19573
19574
19575
2/2
✓ Branch 0 taken 19327198 times.
✓ Branch 1 taken 832 times.
19328030 for(int32_t i=0; i<tiles_used; ++i)
19576 {
19577 19327198 byte format=tf4Bit;
19578 19327198 memset(temp_tile, 0, tilesize(tf32Bit));
19579
19580
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 16341742 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19327198 if((version>0x211)||((version==0x211)&&(build>4)))
19581 {
19582
1/2
✓ Branch 0 taken 16341742 times.
✗ Branch 1 not taken.
16341742 if(!p_getc(&format,f))
19583 {
19584 delete[] temp_tile;
19585 return qe_invalid;
19586 }
19587 16341742 }
19588
4/4
✓ Branch 0 taken 8379212 times.
✓ Branch 1 taken 10947986 times.
✓ Branch 2 taken 3872904 times.
✓ Branch 3 taken 4506308 times.
19327198 if(section_version > 2 && !format)
19589 {
19590 4506308 reset_tile(buf,start_tile+i,tf4Bit);
19591 4506308 continue;
19592 }
19593
19594
2/2
✓ Branch 0 taken 14311620 times.
✓ Branch 1 taken 509270 times.
14820890 int size = format == tf4Bit ? 128 : tilesize(format);
19595
1/2
✓ Branch 0 taken 14820890 times.
✗ Branch 1 not taken.
14820890 if(!pfread(temp_tile,size,f))
19596 {
19597 delete[] temp_tile;
19598 return qe_invalid;
19599 }
19600
19601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14820890 times.
14820890 if (should_skip)
19602 continue;
19603
19604 14820890 buf[start_tile+i].format=format;
19605
19606
2/2
✓ Branch 0 taken 14607216 times.
✓ Branch 1 taken 213674 times.
14820890 if(buf[start_tile+i].data)
19607 {
19608 14607216 free(buf[start_tile+i].data);
19609 14607216 buf[start_tile+i].data=NULL;
19610 14607216 }
19611
19612 14820890 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19613
19614
2/2
✓ Branch 0 taken 14311620 times.
✓ Branch 1 taken 509270 times.
14820890 if (format == tf4Bit)
19615 {
19616 byte temp[256];
19617 14311620 byte *si = temp_tile + 128;
19618 14311620 byte *di = temp + 256;
19619
19620
2/2
✓ Branch 0 taken 1831887360 times.
✓ Branch 1 taken 14311620 times.
1846198980 for(int i=127; i>=0; --i)
19621 {
19622 1831887360 (*(--di)) = (*(--si)) >> 4;
19623 1831887360 (*(--di)) = (*si) & 15;
19624 1831887360 }
19625
19626 14311620 memcpy(buf[start_tile+i].data,temp,256);
19627 14311620 }
19628 else
19629 {
19630 509270 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19631 }
19632 14820890 }
19633 }
19634
19635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (should_skip)
19636 return 0;
19637
19638
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 617 times.
832 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19639 {
19640
2/2
✓ Branch 0 taken 91920660 times.
✓ Branch 1 taken 617 times.
91921277 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19641 {
19642
19643 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19644 91920660 reset_tile(buf,q,tf4Bit);
19645
19646
19647 /*
19648
19649 byte tempbyte;
19650 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19651 {
19652 tempbyte=buf[ZC250MAXTILES-1].data[i];
19653 buf[q].data[i] = tempbyte;
19654 }
19655 //int32_t temp = tempbyte=buf[130].data[i];
19656 //buf[q].data = buf[ZC250MAXTILES-1].data;
19657 */
19658 //reset_tile(buf,q,tf4Bit);
19659 91920660 }
19660
19661 617 }
19662
19663
4/6
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 215 times.
832 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19664 {
19665
2/2
✓ Branch 0 taken 30945450 times.
✓ Branch 1 taken 617 times.
30946067 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19666 {
19667 30945450 reset_tile(buf,i,tf4Bit);
19668 30945450 }
19669 617 }
19670 else
19671 {
19672
2/2
✓ Branch 0 taken 37164572 times.
✓ Branch 1 taken 215 times.
37164787 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19673 {
19674 37164572 reset_tile(buf,i,tf4Bit);
19675 37164572 }
19676 }
19677
19678
5/6
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 808 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
832 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19679 {
19680
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19681 {
19682 byte tempbyte;
19683 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19684
19685
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19686 {
19687 1536 tempbyte=buf[23].data[i];
19688 1536 buf[23].data[i]=buf[24].data[i];
19689 1536 buf[24].data[i]=buf[25].data[i];
19690 1536 buf[25].data[i]=buf[26].data[i];
19691 1536 buf[26].data[i]=tempbyte;
19692 1536 }
19693 //swim tiles are out of order, too, but nobody cared? -Z
19694
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19695 {
19696 1536 tempbyte=buf[floattile+11].data[i];
19697 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19698 1536 buf[floattile+12].data[i]=tempbyte;
19699 1536 }
19700 6 }
19701 24 }
19702
19703
3/6
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 749 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19704 {
19705
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19706 {
19707 byte tempbyte;
19708
19709
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19710 {
19711 5632 tempbyte=buf[130].data[i];
19712 5632 buf[130].data[i]=buf[132].data[i];
19713 5632 buf[132].data[i]=tempbyte;
19714
19715 5632 tempbyte=buf[131].data[i];
19716 5632 buf[131].data[i]=buf[133].data[i];
19717 5632 buf[133].data[i]=tempbyte;
19718 5632 }
19719 22 }
19720 83 }
19721
19722 832 al_trace("Registering blank tiles\n");
19723 832 register_blank_tiles();
19724
19725 //memset(temp_tile, 0, tilesize(tf32Bit));
19726
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 delete[] temp_tile;
19727 832 temp_tile=NULL;
19728 832 return 0;
19729 832 }
19730
19731 497 int32_t readmidis(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19732 {
19733
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19734
19735 byte temp_midi_flags[32];
19736
19737 int32_t dummy;
19738 word dummy2;
19739 // zcmidi_ temp_midi;
19740 word tunes_to_read;
19741 497 word section_version=0;
19742 497 zctune temp;
19743 497 char old_title[37] = {0};
19744
19745
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 474 times.
497 if(Header->zelda_version < 0x193)
19746 {
19747
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19748 {
19749 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19750 22 }
19751 else
19752 {
19753 1 tunes_to_read=MAXCUSTOMMIDIS;
19754 }
19755 23 }
19756 else
19757 {
19758 //section version info
19759
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&section_version,f))
19760 {
19761 return qe_invalid;
19762 }
19763
19764
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (section_version > V_MIDIS)
19765 return qe_version;
19766
19767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (!should_skip)
19768 474 FFCore.quest_format[vMIDIs] = section_version;
19769
19770
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&dummy2,f))
19771 {
19772 return qe_invalid;
19773 }
19774
19775 //section size
19776
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&dummy,f))
19777 {
19778 return qe_invalid;
19779 }
19780
19781 //finally... section data
19782
19783
2/2
✓ Branch 0 taken 397 times.
✓ Branch 1 taken 77 times.
474 if (section_version < 5)
19784 {
19785
2/4
✓ Branch 0 taken 397 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 397 times.
✗ Branch 3 not taken.
397 if(!pfread(temp_midi_flags,32,f))
19786 return qe_invalid;
19787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 397 times.
397 vector<byte> vb{ temp_midi_flags, temp_midi_flags + 32 };
19788
2/4
✓ Branch 0 taken 397 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 397 times.
✗ Branch 3 not taken.
397 midi_bitstr.inner() = vb;
19789 397 tunes_to_read = 252;
19790 397 }
19791 else
19792 {
19793
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if (!p_getbitstr(&midi_bitstr, f))
19794 return qe_invalid;
19795
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if (!p_igetw(&tunes_to_read, f))
19796 return qe_invalid;
19797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if (tunes_to_read > MAXCUSTOMMIDIS)
19798 return qe_invalid;
19799 }
19800 }
19801
19802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if (!should_skip)
19803
2/2
✓ Branch 0 taken 254464 times.
✓ Branch 1 taken 497 times.
254961 for(uint q = 0; q < MAXCUSTOMMIDIS; ++q)
19804
1/2
✓ Branch 0 taken 254464 times.
✗ Branch 1 not taken.
254961 tunes[q].reset();
19805
19806
2/2
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 101408 times.
101905 for(uint i = 0; i < tunes_to_read; ++i)
19807 {
19808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101408 times.
101408 auto& temp_tune = should_skip ? temp : tunes[i];
19809
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 101408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
101408 if (should_skip) temp.reset();
19810
19811
3/4
✓ Branch 0 taken 101408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 91077 times.
101408 if (!midi_bitstr.get(i)) continue;
19812
19813
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 10183 times.
10331 if (section_version > 4)
19814 {
19815
2/4
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
148 if (!p_getwstr(&temp_tune.song_title, f))
19816 return qe_invalid;
19817 148 }
19818
2/2
✓ Branch 0 taken 7520 times.
✓ Branch 1 taken 2663 times.
10183 else if (section_version == 4)
19819 {
19820
2/4
✓ Branch 0 taken 7520 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7520 times.
7520 if (!p_getstr(old_title,36,f))
19821 return qe_invalid;
19822
1/2
✓ Branch 0 taken 7520 times.
✗ Branch 1 not taken.
7520 temp_tune.song_title = old_title;
19823 7520 }
19824
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 else if (section_version < 4)
19825 {
19826
2/4
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2663 times.
✗ Branch 3 not taken.
2663 if (!p_getstr(old_title,20,f))
19827 return qe_invalid;
19828
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 temp_tune.song_title = old_title;
19829 2663 }
19830
19831
2/4
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10331 times.
✗ Branch 3 not taken.
10331 if (!p_igetl(&temp_tune.start,f))
19832 return qe_invalid;
19833
19834
2/4
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10331 times.
✗ Branch 3 not taken.
10331 if (!p_igetl(&temp_tune.loop_start,f))
19835 return qe_invalid;
19836
19837
2/4
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10331 times.
✗ Branch 3 not taken.
10331 if (!p_igetl(&temp_tune.loop_end,f))
19838 return qe_invalid;
19839
19840
2/4
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10331 times.
✗ Branch 3 not taken.
10331 if (!p_igetw(&temp_tune.loop,f))
19841 return qe_invalid;
19842
19843
2/4
✓ Branch 0 taken 10331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10331 times.
✗ Branch 3 not taken.
10331 if (!p_igetw(&temp_tune.volume,f))
19844 return qe_invalid;
19845
19846
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 10082 times.
10331 if (Header->zelda_version < 0x193)
19847
2/4
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
249 if(!p_igetl(&dummy,f))
19848 return qe_invalid;
19849
19850
2/2
✓ Branch 0 taken 7668 times.
✓ Branch 1 taken 2663 times.
10331 if (section_version >= 3)
19851
2/4
✓ Branch 0 taken 7668 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7668 times.
✗ Branch 3 not taken.
7668 if(!pfread(&temp_tune.flags,sizeof(temp_tune.flags),f))
19852 return qe_invalid;
19853
19854
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7668 times.
10331 if (section_version < 2)
19855 {
19856
2/4
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2663 times.
✗ Branch 3 not taken.
2663 if((temp_tune.data=read_midi(f))==NULL)
19857 return qe_invalid;
19858 2663 }
19859 else
19860 {
19861 byte format;
19862
2/4
✓ Branch 0 taken 7668 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7668 times.
✗ Branch 3 not taken.
7668 if(!pfread(&format,sizeof(format),f))
19863 return qe_invalid;
19864
19865 // MIDI is the only format saved here.
19866 // Never did more than MIDI for a zctune, and no plans to now.
19867
1/2
✓ Branch 0 taken 7668 times.
✗ Branch 1 not taken.
7668 if (format != MFORMAT_MIDI)
19868 return qe_invalid;
19869
19870
1/2
✓ Branch 0 taken 7668 times.
✗ Branch 1 not taken.
7668 temp_tune.data = read_midi(f);
19871
1/2
✓ Branch 0 taken 7668 times.
✗ Branch 1 not taken.
7668 if (!temp_tune.data)
19872 return qe_invalid;
19873 }
19874 10331 }
19875
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 temp.reset();
19876 497 return 0;
19877 497 }
19878
19879 497 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19880 {
19881
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19882
19883 int32_t dummy;
19884 ZCHEATS tempzcheats;
19885 497 char temp_use_cheats=1;
19886 497 memset(&tempzcheats, 0, sizeof(tempzcheats));
19887 497 word s_version = 0;
19888
19889
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 474 times.
497 if(Header->zelda_version > 0x192)
19890 {
19891 //section version info
19892
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&s_version,f))
19893 {
19894 return qe_invalid;
19895 }
19896
19897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if (s_version > V_CHEATS)
19898 return qe_version;
19899
19900 474 FFCore.quest_format[vCheats] = s_version;
19901
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetw(&dummy,f))
19902 {
19903 return qe_invalid;
19904 }
19905
19906 //section size
19907
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(!p_igetl(&dummy,f))
19908 {
19909 return qe_invalid;
19910 }
19911
19912 //finally... section data
19913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(!p_getc(&temp_use_cheats,f))
19914 {
19915 return qe_invalid;
19916 }
19917 474 }
19918
19919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if(Header->data_flags[ZQ_CHEATS2])
19920 {
19921
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 if(!p_igetl(&tempzcheats.flags,f))
19922 {
19923 return qe_invalid;
19924 }
19925
19926
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19927 {
19928 return qe_invalid;
19929 }
19930 497 }
19931
19932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if (should_skip)
19933 return 0;
19934
19935 497 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19936 497 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19937
19938 497 return 0;
19939 497 }
19940
19941 299 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19942 {
19943
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
299 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19944
19945 byte padding, tempbyte;
19946
19947 // Legacy item properties (now integrated into itemdata)
19948 byte sword_hearts[4];
19949 byte beam_hearts[4];
19950 299 byte beam_percent=0;
19951 word beam_power[4];
19952 299 byte hookshot_length=99;
19953 299 byte hookshot_links=100;
19954 299 byte longshot_length=99;
19955 299 byte longshot_links=100;
19956 299 byte moving_fairy_hearts=3;
19957 299 byte moving_fairy_heart_percent=0;
19958 299 byte stationary_fairy_hearts=3;
19959 299 byte stationary_fairy_heart_percent=0;
19960 299 byte moving_fairy_magic=0;
19961 299 byte moving_fairy_magic_percent=0;
19962 299 byte stationary_fairy_magic=0;
19963 299 byte stationary_fairy_magic_percent=0;
19964 299 byte blue_potion_hearts=100;
19965 299 byte blue_potion_heart_percent=1;
19966 299 byte red_potion_hearts=100;
19967 299 byte red_potion_heart_percent=1;
19968 299 byte blue_potion_magic=100;
19969 299 byte blue_potion_magic_percent=1;
19970 299 byte red_potion_magic=100;
19971 299 byte red_potion_magic_percent=1;
19972
19973 299 byte bomb_ratio = 4;
19974
19975 299 subscr_mode = 0;
19976
19977 /* HIGHLY UNORTHODOX UPDATING THING, by L
19978 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19979 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19980 * changing from 13 to 14.
19981 */
19982
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 14)
19983 82 fixpolsvoice=true;
19984
19985 /* End highly unorthodox updating thing */
19986
19987
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 111 times.
299 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19988 111 temp_zinit.jump_hero_layer_threshold=0;
19989
19990
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
299 if(s_version >= 10)
19991 {
19992 char temp;
19993
19994 //new-style items
19995
2/2
✓ Branch 0 taken 55552 times.
✓ Branch 1 taken 217 times.
55769 for(int32_t j=0; j<256; j++)
19996 {
19997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55552 times.
55552 if(!p_getc(&temp,f))
19998 return qe_invalid;
19999
20000 55552 temp_zinit.set_item(j, temp != 0);
20001 55552 }
20002 217 }
20003
20004
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
20005 {
20006 char temp;
20007
20008 //finally... section data
20009
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
20010 //new only
20011
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20012 {
20013 //OLD-style items... sigh
20014
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 60 times.
277 if(s_version < 10)
20015 {
20016
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20017 {
20018 return qe_invalid;
20019 }
20020
20021 60 temp_zinit.set_item(iRaft, temp != 0);
20022
20023
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20024 {
20025 return qe_invalid;
20026 }
20027
20028 60 temp_zinit.set_item(iLadder, temp != 0);
20029
20030
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20031 {
20032 return qe_invalid;
20033 }
20034
20035 60 temp_zinit.set_item(iBook, temp != 0);
20036
20037
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20038 {
20039 return qe_invalid;
20040 }
20041
20042 60 temp_zinit.set_item(iMKey, temp != 0);
20043
20044
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20045 {
20046 return qe_invalid;
20047 }
20048
20049 60 temp_zinit.set_item(iFlippers, temp != 0);
20050
20051
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20052 {
20053 return qe_invalid;
20054 }
20055
20056 60 temp_zinit.set_item(iBoots, temp != 0);
20057 60 }
20058 277 }
20059
20060
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
20061 {
20062 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
20063
20064
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
20065 {
20066 return qe_invalid;
20067 }
20068
20069
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
20070 {
20071 return qe_invalid;
20072 }
20073
20074
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
20075 {
20076 return qe_invalid;
20077 }
20078
20079
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
20080 {
20081 return qe_invalid;
20082 }
20083
20084
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
20085 {
20086 return qe_invalid;
20087 }
20088
20089
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
20090 {
20091 return qe_invalid;
20092 }
20093
20094
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
20095 {
20096 return qe_invalid;
20097 }
20098
20099 //old only
20100
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
20101 {
20102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
20103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
20104
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
20105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
20106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
20107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
20108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
20109 4 }
20110
20111 //rings start at level 2... wtf
20112 //account for this -DD
20113 64 tempring <<= 1;
20114 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
20115 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
20116 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
20117 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
20118 //bracelet ALSO starts at level 2 :-( -DD
20119 64 tempbracelet<<=1;
20120 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
20121 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
20122 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
20123
20124 //new only
20125
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
20126 {
20127
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20128 {
20129
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20130 {
20131 return qe_invalid;
20132 }
20133 32 }
20134 1 }
20135
20136 char tempcandle, tempboomerang, temparrow, tempwhistle;
20137
20138
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
20139 {
20140 return qe_invalid;
20141 }
20142
20143
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
20144 {
20145 return qe_invalid;
20146 }
20147
20148
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
20149 {
20150 return qe_invalid;
20151 }
20152
20153
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
20154 {
20155 return qe_invalid;
20156 }
20157
20158 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
20159
20160
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
20161 {
20162 return qe_invalid;
20163 }
20164
20165 //old only
20166
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
20167 {
20168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
20169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
20170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
20171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
20172 4 }
20173
20174 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
20175 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
20176 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
20177 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
20178 //What about the potion...?
20179
20180 64 }
20181
20182
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20183 {
20184 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
20185 //to jab out my eye...
20186
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20187 return qe_invalid;
20188 264 temp_zinit.counter[crBOMBS] = padding;
20189
20190
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20191 return qe_invalid;
20192 264 temp_zinit.counter[crSBOMBS] = padding;
20193 264 }
20194
20195 //Back to more OLD item code
20196
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
20197 {
20198
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
20199 //new only
20200
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20201 {
20202
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20203 {
20204 return qe_invalid;
20205 }
20206
20207 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
20208
20209
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20210 {
20211 return qe_invalid;
20212 }
20213
20214 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
20215
20216
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20217 {
20218 return qe_invalid;
20219 }
20220
20221 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
20222
20223
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20224 {
20225 return qe_invalid;
20226 }
20227
20228 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
20229
20230
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20231 {
20232 return qe_invalid;
20233 }
20234
20235 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
20236
20237
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20238 {
20239 return qe_invalid;
20240 }
20241
20242 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
20243
20244
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20245 {
20246 return qe_invalid;
20247 }
20248
20249 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
20250
20251
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20252 {
20253 return qe_invalid;
20254 }
20255
20256 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
20257
20258
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20259 {
20260 return qe_invalid;
20261 }
20262
20263 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
20264
20265
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20266 {
20267 return qe_invalid;
20268 }
20269
20270
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
20271 {
20272
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20273 {
20274
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20275 {
20276 return qe_invalid;
20277 }
20278 32 }
20279 1 }
20280 60 }
20281 64 }
20282
20283 //old only
20284
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20285 {
20286 byte equipment, tmpitm; //bit flags
20287
20288
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
20289 {
20290 return qe_invalid;
20291 }
20292
20293 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
20294 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
20295 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
20296 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
20297 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
20298 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
20299
20300
20301
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
20302 {
20303 return qe_invalid;
20304 }
20305
20306 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
20307 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
20308 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
20309 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
20310 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
20311 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
20312 4 }
20313
20314
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20315 return qe_invalid;
20316 281 temp_zinit.mcounter[crLIFE] = tempbyte;
20317
20318
20319
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20320 {
20321 byte temphp;
20322
20323
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20324 {
20325 return qe_invalid;
20326 }
20327
20328 64 temp_zinit.counter[crLIFE]=temphp;
20329
20330
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20331 {
20332 return qe_invalid;
20333 }
20334
20335 64 temp_zinit.cont_heart=temphp;
20336 64 }
20337 else
20338 {
20339
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
20340 {
20341 return qe_invalid;
20342 }
20343
20344
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.cont_heart,f))
20345 {
20346 return qe_invalid;
20347 }
20348 }
20349
20350
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.hcp,f))
20351 {
20352 return qe_invalid;
20353 }
20354
20355
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version >= 14)
20356 {
20357
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20358 {
20359 return qe_invalid;
20360 }
20361
20362
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(s_version<16) // July 2007
20363 {
20364 if(get_qr(qr_BRANGPICKUP+1))
20365 temp_zinit.hcp_per_hc = 0xFF;
20366
20367 //Dispose of legacy rule
20368 set_qr(qr_BRANGPICKUP+1, 0);
20369 }
20370 217 }
20371
20372
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20373 {
20374
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20375 return qe_invalid;
20376 264 temp_zinit.mcounter[crBOMBS] = padding;
20377 264 }
20378
20379
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.counter[crKEYS],f))
20380 {
20381 return qe_invalid;
20382 }
20383
20384
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
20385 {
20386 return qe_invalid;
20387 }
20388
20389
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20390 return qe_invalid;
20391
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 281 times.
2529 for(int q = 0; q < 8; ++q)
20392
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 1744 times.
2248 SETFLAG(temp_zinit.litems[q+1], (1 << li_mcguffin), get_bitl(tempbyte, q));
20393
20394 281 int level_count = 32;
20395
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
281 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20396 217 level_count = 64;
20397 byte tmp_map[64];
20398 byte tmp_compass[64];
20399
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20400
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_map[i],f))
20401 return qe_invalid;
20402
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20403
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_compass[i],f))
20404 return qe_invalid;
20405
2/2
✓ Branch 0 taken 127488 times.
✓ Branch 1 taken 281 times.
127769 for(int q = 0; q < level_count*8; ++q)
20406 {
20407
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 126692 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
20408
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 127479 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
20409 127488 }
20410
20411
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
20412 //new only
20413
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20414 {
20415 byte tmp_boss_key[64];
20416
2/2
✓ Branch 0 taken 15808 times.
✓ Branch 1 taken 277 times.
16085 for(int32_t i=0; i<level_count; i++)
20417 {
20418
1/2
✓ Branch 0 taken 15808 times.
✗ Branch 1 not taken.
15808 if(!p_getc(&tmp_boss_key[i],f))
20419 {
20420 return qe_invalid;
20421 }
20422 15808 }
20423
2/2
✓ Branch 0 taken 126464 times.
✓ Branch 1 taken 277 times.
126741 for(int q = 0; q < level_count*8; ++q)
20424 {
20425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126464 times.
126464 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20426 126464 }
20427 277 }
20428
20429 byte tmpmisc[16];
20430
2/2
✓ Branch 0 taken 4496 times.
✓ Branch 1 taken 281 times.
4777 for(int32_t i=0; i<16; i++)
20431
1/2
✓ Branch 0 taken 4496 times.
✗ Branch 1 not taken.
4496 if(!p_getc(&tmpmisc[i],f))
20432 return qe_invalid;
20433 281 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
20434 281 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
20435 281 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
20436
20437
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
537 if(s_version < 15) for(int32_t i=0; i<4; i++)
20438
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
20439 64 return qe_invalid;
20440
20441
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_map,f))
20442 {
20443 return qe_invalid;
20444 }
20445
20446
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_screen,f))
20447 {
20448 return qe_invalid;
20449 }
20450
20451
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20452 {
20453 byte tempmp;
20454
20455
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20456 {
20457 return qe_invalid;
20458 }
20459
20460 64 temp_zinit.mcounter[crMAGIC]=tempmp;
20461
20462
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20463 {
20464 return qe_invalid;
20465 }
20466
20467 64 temp_zinit.counter[crMAGIC]=tempmp;
20468 64 }
20469 else
20470 {
20471
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
20472 {
20473 return qe_invalid;
20474 }
20475
20476
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
20477 {
20478 return qe_invalid;
20479 }
20480 }
20481
20482
20483
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 15)
20484 {
20485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
20486 {
20487 64 temp_zinit.mcounter[crMAGIC]*=32;
20488 64 temp_zinit.counter[crMAGIC]*=32;
20489 64 }
20490
20491
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20492 {
20493
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
20494 {
20495 return qe_invalid;
20496 }
20497 256 }
20498
20499
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
20500 {
20501 return qe_invalid;
20502 }
20503 64 }
20504 else
20505 {
20506
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.bomb_ratio,f))
20507 return qe_invalid;
20508
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(temp_zinit.bomb_ratio < 1)
20509 temp_zinit.bomb_ratio = 1;
20510 217 else bomb_ratio = temp_zinit.bomb_ratio; //jank
20511 }
20512
20513
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 15)
20514 {
20515 byte tempbp;
20516
20517
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20518 {
20519
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20520 {
20521 return qe_invalid;
20522 }
20523
20524 256 beam_power[i]=tempbp;
20525 256 }
20526
20527
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
20528 {
20529 return qe_invalid;
20530 }
20531
20532
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20533 {
20534 if(!p_getc(&hookshot_length,f))
20535 {
20536 return qe_invalid;
20537 }
20538
20539 if(!p_getc(&longshot_links,f))
20540 {
20541 return qe_invalid;
20542 }
20543
20544 if(!p_getc(&longshot_length,f))
20545 {
20546 return qe_invalid;
20547 }
20548 }
20549 64 }
20550
20551
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_x,f))
20552 {
20553 return qe_invalid;
20554 }
20555
20556
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_y,f))
20557 {
20558 return qe_invalid;
20559 }
20560
20561
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&subscr_mode,f))
20562 return qe_invalid;
20563
20564 //old only
20565
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20566 {
20567 byte tmp_boss_key[32];
20568
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20569 {
20570
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tmp_boss_key[i],f))
20571 {
20572 return qe_invalid;
20573 }
20574 128 }
20575
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int q = 0; q < 32*8; ++q)
20576 {
20577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20578 1024 }
20579 4 }
20580
20581
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
281 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20582 {
20583
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 217 times.
277 if(s_version <= 10)
20584 {
20585
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20586 {
20587 return qe_invalid;
20588 }
20589
20590 60 temp_zinit.start_dmap = (word)tempbyte;
20591 60 }
20592 else
20593 {
20594
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.start_dmap,f))
20595 {
20596 return qe_invalid;
20597 }
20598 }
20599
20600
1/2
✓ Branch 0 taken 277 times.
✗ Branch 1 not taken.
277 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20601 {
20602 return qe_invalid;
20603 }
20604 277 }
20605
20606
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 200 times.
281 if(s_version>1 && s_version < 29)
20607 {
20608
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20609 return qe_invalid;
20610 200 temp_zinit.counter[crARROWS] = padding;
20611
20612
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20613 return qe_invalid;
20614 200 temp_zinit.mcounter[crARROWS] = padding;
20615 200 }
20616
20617
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>2)
20618 {
20619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(s_version <= 10)
20620 {
20621 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20622 {
20623 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20624 {
20625 return qe_invalid;
20626 }
20627 }
20628 }
20629 else
20630 {
20631
2/2
✓ Branch 0 taken 111104 times.
✓ Branch 1 taken 217 times.
111321 for(int32_t i=0; i<MAXLEVELS; i++)
20632 {
20633
1/2
✓ Branch 0 taken 111104 times.
✗ Branch 1 not taken.
111104 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20634 {
20635 return qe_invalid;
20636 }
20637 111104 }
20638 }
20639 217 }
20640
20641
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>3)
20642 {
20643
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20644 {
20645 return qe_invalid;
20646 }
20647
20648
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20649 {
20650 return qe_invalid;
20651 }
20652
20653
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20654 {
20655 return qe_invalid;
20656 }
20657
20658
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20659 {
20660 return qe_invalid;
20661 }
20662
20663
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20664 {
20665 return qe_invalid;
20666 }
20667
20668
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20669 {
20670 return qe_invalid;
20671 }
20672
20673
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20674 {
20675 return qe_invalid;
20676 }
20677
20678
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_flags,f))
20679 {
20680 return qe_invalid;
20681 }
20682
20683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20685 217 }
20686
20687
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>4 && s_version<15)
20688 {
20689 if(!p_getc(&moving_fairy_hearts,f))
20690 {
20691 return qe_invalid;
20692 }
20693
20694 if(!p_getc(&moving_fairy_heart_percent,f))
20695 {
20696 return qe_invalid;
20697 }
20698 }
20699
20700
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>5 && s_version < 10)
20701 {
20702 if(!p_getc(&temp,f))
20703 {
20704 return qe_invalid;
20705 }
20706
20707 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20708 }
20709
20710
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>6 && s_version<15)
20711 {
20712 if(!p_getc(&stationary_fairy_hearts,f))
20713 {
20714 return qe_invalid;
20715 }
20716
20717 if(!p_getc(&stationary_fairy_heart_percent,f))
20718 {
20719 return qe_invalid;
20720 }
20721
20722 if(!p_getc(&moving_fairy_magic,f))
20723 {
20724 return qe_invalid;
20725 }
20726
20727 if(!p_getc(&moving_fairy_magic_percent,f))
20728 {
20729 return qe_invalid;
20730 }
20731
20732 if(!p_getc(&stationary_fairy_magic,f))
20733 {
20734 return qe_invalid;
20735 }
20736
20737 if(!p_getc(&stationary_fairy_magic_percent,f))
20738 {
20739 return qe_invalid;
20740 }
20741
20742 if(!p_getc(&blue_potion_hearts,f))
20743 {
20744 return qe_invalid;
20745 }
20746
20747 if(!p_getc(&blue_potion_heart_percent,f))
20748 {
20749 return qe_invalid;
20750 }
20751
20752 if(!p_getc(&red_potion_hearts,f))
20753 {
20754 return qe_invalid;
20755 }
20756
20757 if(!p_getc(&red_potion_heart_percent,f))
20758 {
20759 return qe_invalid;
20760 }
20761
20762 if(!p_getc(&blue_potion_magic,f))
20763 {
20764 return qe_invalid;
20765 }
20766
20767 if(!p_getc(&blue_potion_magic_percent,f))
20768 {
20769 return qe_invalid;
20770 }
20771
20772 if(!p_getc(&red_potion_magic,f))
20773 {
20774 return qe_invalid;
20775 }
20776
20777 if(!p_getc(&red_potion_magic_percent,f))
20778 {
20779 return qe_invalid;
20780 }
20781 }
20782
20783
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>6)
20784
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20785 return qe_invalid;
20786
20787
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>7)
20788 {
20789
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20790 {
20791 return qe_invalid;
20792 }
20793 217 }
20794
20795
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>8)
20796 {
20797
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20798 {
20799 return qe_invalid;
20800 }
20801
20802
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20803 {
20804 return qe_invalid;
20805 }
20806 217 }
20807
20808
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version>16)
20809 {
20810
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&tempbyte,f))
20811 {
20812 return qe_invalid;
20813 }
20814 217 temp_zinit.gravity = tempbyte*100;
20815
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.terminalv,f))
20816 {
20817 return qe_invalid;
20818 }
20819
20820
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_speed,f))
20821 {
20822 return qe_invalid;
20823 }
20824
20825
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20826 {
20827 return qe_invalid;
20828 }
20829
20830
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20831 {
20832 return qe_invalid;
20833 }
20834 217 }
20835
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20836 12 temp_zinit.msg_speed = 0;
20837
20838
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>17)
20839 {
20840
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20841 {
20842 return qe_invalid;
20843 }
20844 217 }
20845
20846 //expaned init data for larger values in 2.55
20847
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 17 times.
281 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20848 {
20849
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20850 {
20851 return qe_invalid;
20852 }
20853
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20854 {
20855 return qe_invalid;
20856 }
20857
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20858 {
20859 return qe_invalid;
20860 }
20861
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20862 {
20863 return qe_invalid;
20864 }
20865
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20866 {
20867 return qe_invalid;
20868 }
20869
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20870 {
20871 return qe_invalid;
20872 }
20873
20874 17 }
20875
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 20 )
20876 {
20877
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20878 {
20879 return qe_invalid;
20880 }
20881 17 }
20882 else
20883 {
20884 264 temp_zinit.heroStep = 150; //1.5 pixels per frame
20885 }
20886
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 21 )
20887 {
20888
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20889 {
20890 return qe_invalid;
20891 }
20892 17 }
20893 else
20894 {
20895 264 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20896 }
20897 //old only
20898
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20899 {
20900 byte items2;
20901
20902
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20903 {
20904 return qe_invalid;
20905 }
20906
20907 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20908 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20909 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20910 4 }
20911
20912
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 5 times.
281 if(Header->zelda_version < 0x193)
20913 {
20914
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20915 {
20916
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20917 {
20918 return qe_invalid;
20919 }
20920 480 }
20921
20922 //new only
20923
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20924 {
20925
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20926 {
20927 return qe_invalid;
20928 }
20929
20930
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20931 {
20932 return qe_invalid;
20933 }
20934 1 }
20935 5 }
20936 281 }
20937
20938
3/6
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 217 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20939 {
20940 //temp_zinit.shield=i_smallshield;
20941 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20942
20943
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20944 82 temp_zinit.set_item(sshieldid, true);
20945 82 }
20946
20947
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20948 {
20949 18 temp_zinit.mcounter[crLIFE]=3;
20950 18 temp_zinit.counter[crLIFE]=3;
20951 18 temp_zinit.cont_heart=3;
20952 18 temp_zinit.mcounter[crBOMBS]=8;
20953 18 }
20954
20955
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20956 {
20957 18 sword_hearts[0]=0;
20958 18 sword_hearts[1]=5;
20959 18 sword_hearts[2]=12;
20960 18 sword_hearts[3]=21;
20961 18 }
20962
20963
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20964 {
20965 18 temp_zinit.last_map=0;
20966 18 temp_zinit.last_screen=0;
20967 18 }
20968
20969
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20970 {
20971 18 temp_zinit.mcounter[crMAGIC]=0;
20972 18 temp_zinit.counter[crMAGIC]=0;
20973 18 temp_zinit.magicdrainrate = 2;
20974 18 }
20975
20976
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20977 {
20978
20979
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20980 {
20981 72 beam_hearts[x]=100;
20982 72 }
20983
20984
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20985 {
20986 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20987 72 set_qr(qr_LENSHINTS+i,0);
20988 72 }
20989
20990
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20991 {
20992 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20993 72 }
20994
20995 18 set_qr(qr_HIDECARRIEDITEMS,0);
20996 18 hookshot_links=100;
20997 18 temp_zinit.msg_more_x=224;
20998 18 temp_zinit.msg_more_y=64;
20999 18 }
21000
21001 // Okay, let's put these legacy values into itemsbuf.
21002
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 15)
21003
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
21004 {
21005
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
21006 {
21007 case iFairyStill:
21008 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
21009 82 itemsbuf[i].misc2 = stationary_fairy_magic;
21010 82 itemsbuf[i].misc3 = 0;
21011
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
21012
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
21013 82 break;
21014
21015 case iFairyMoving:
21016 82 itemsbuf[i].misc1 = moving_fairy_hearts;
21017 82 itemsbuf[i].misc2 = moving_fairy_magic;
21018 82 itemsbuf[i].misc3 = 50;
21019
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
21020
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
21021 82 break;
21022
21023 case iRPotion:
21024 82 itemsbuf[i].misc1 = red_potion_hearts;
21025 82 itemsbuf[i].misc2 = red_potion_magic;
21026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
21027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
21028 82 break;
21029
21030 case iBPotion:
21031 82 itemsbuf[i].misc1 = blue_potion_hearts;
21032 82 itemsbuf[i].misc2 = blue_potion_magic;
21033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
21034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
21035 82 break;
21036
21037 case iSword:
21038 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
21039 82 itemsbuf[i].misc1 = beam_hearts[0];
21040 82 itemsbuf[i].misc2 = beam_power[0];
21041 // It seems that item_flag1 was already added by reset_itembuf()...
21042 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
21043 82 break;
21044
21045 case iWSword:
21046 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
21047 82 itemsbuf[i].misc1 = beam_hearts[1];
21048 82 itemsbuf[i].misc2 = beam_power[1];
21049 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
21050 82 break;
21051
21052 case iMSword:
21053 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
21054 82 itemsbuf[i].misc1 = beam_hearts[2];
21055 82 itemsbuf[i].misc2 = beam_power[2];
21056 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
21057 82 break;
21058
21059 case iXSword:
21060 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
21061 82 itemsbuf[i].misc1 = beam_hearts[3];
21062 82 itemsbuf[i].misc2 = beam_power[3];
21063 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
21064 82 break;
21065
21066 case iHookshot:
21067 82 itemsbuf[i].misc1 = hookshot_length;
21068 82 itemsbuf[i].misc2 = hookshot_links;
21069 82 break;
21070
21071 case iLongshot:
21072 82 itemsbuf[i].misc1 = longshot_length;
21073 82 itemsbuf[i].misc2 = longshot_links;
21074 82 break;
21075 }
21076 21074 }
21077
21078
6/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
21079 {
21080 //was new subscreen rule
21081 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
21082 22 set_qr(qr_FREEFORM,0);
21083 22 }
21084
21085
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
21086 {
21087 23 temp_zinit.start_dmap=0;
21088 23 }
21089
21090
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
21091 {
21092 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
21093 23 }
21094
21095
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
299 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
21096 {
21097 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
21098 temp_zinit.mcounter[crMONEY]=999;
21099 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
21100 }
21101
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
21102 {
21103 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
21104 6 temp_zinit.mcounter[crBOMBS] = 8;
21105 6 }
21106 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
21107 //time to ensure that we port all new values properly:
21108
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(Header->zelda_version < 0x250)
21109 {
21110
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
21111 82 }
21112
21113
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 21)
21114 {
21115
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
21116 {
21117 return qe_invalid;
21118 }
21119
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
21120 {
21121 return qe_invalid;
21122 }
21123
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21124 {
21125 return qe_invalid;
21126 }
21127
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21128 {
21129 return qe_invalid;
21130 }
21131 17 }
21132 else
21133 {
21134 282 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
21135 282 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
21136 282 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
21137 282 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
21138 }
21139
21140
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 22)
21141 {
21142
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
21143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
21144 return qe_invalid;
21145
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
21146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
21147 return qe_invalid;
21148 17 }
21149
21150
21151
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 23)
21152 {
21153
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
21154 {
21155 return qe_invalid;
21156 }
21157
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
21158 {
21159 return qe_invalid;
21160 }
21161
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
21162 {
21163 return qe_invalid;
21164 }
21165
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
21166 {
21167 return qe_invalid;
21168 }
21169
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
21170 {
21171 return qe_invalid;
21172 }
21173 17 }
21174 else
21175 {
21176 282 temp_zinit.dither_type = 0;
21177 282 temp_zinit.dither_arg = 0;
21178 282 temp_zinit.dither_percent = 20;
21179 282 temp_zinit.def_lightrad = 24;
21180 282 temp_zinit.transdark_percent = 0;
21181 }
21182
21183
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 24)
21184 {
21185
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
21186 {
21187 return qe_invalid;
21188 }
21189 17 }
21190 else
21191 {
21192 282 temp_zinit.darkcol = BLACK;
21193 }
21194
21195
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 25)
21196 {
21197
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
21198 {
21199 return qe_invalid;
21200 }
21201
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
21202 {
21203 return qe_invalid;
21204 }
21205 17 }
21206
21207
21208
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 26)
21209 {
21210
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21211 {
21212 return qe_invalid;
21213 }
21214
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21215 {
21216 return qe_invalid;
21217 }
21218
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21219 {
21220 return qe_invalid;
21221 }
21222 17 }
21223 else
21224 {
21225 282 temp_zinit.heroSideswimUpStep = 150;
21226 282 temp_zinit.heroSideswimSideStep = 100;
21227 282 temp_zinit.heroSideswimDownStep = 75;
21228 }
21229
21230
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 27)
21231 {
21232
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21233 {
21234 return qe_invalid;
21235 }
21236 17 }
21237 else
21238 {
21239 282 temp_zinit.exitWaterJump = 0;
21240 }
21241
21242
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 29)
21243 {
21244
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21245 {
21246 return qe_invalid;
21247 }
21248 17 }
21249 else
21250 {
21251 282 temp_zinit.bunny_ltm = 0;
21252 }
21253
21254
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 30)
21255 {
21256
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
21257 {
21258 return qe_invalid;
21259 }
21260 17 }
21261 else
21262 {
21263 282 temp_zinit.switchhookstyle = 1;
21264 }
21265
21266
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 31)
21267 {
21268
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
21269 {
21270 return qe_invalid;
21271 }
21272 17 }
21273
21274 299 temp_zinit.clear_genscript();
21275
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 12 times.
299 if(s_version > 32)
21276 {
21277 12 word numgenscript = 0;
21278
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
21279 return qe_invalid;
21280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
21281 return qe_invalid;
21282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
21283 {
21284 if(!p_getc(&tempbyte,f))
21285 return qe_invalid;
21286 if(!(tempbyte&2))
21287 continue;
21288 temp_zinit.gen_doscript.set(q, tempbyte&1);
21289 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
21290 return qe_invalid;
21291 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
21292 return qe_invalid;
21293 for(auto p = 0; p < 8; ++p)
21294 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
21295 return qe_invalid;
21296 dword sz;
21297 if(!p_igetl(&sz,f))
21298 return qe_invalid;
21299 temp_zinit.gen_data[q].resize(sz);
21300 std::vector<int32_t> dummy;
21301 if(!p_getlvec(&dummy,f))
21302 return qe_invalid;
21303 temp_zinit.gen_data[q] = dummy;
21304 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
21305 return qe_invalid;
21306 }
21307 12 }
21308
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(s_version > 33)
21309 {
21310
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21311 return qe_invalid;
21312
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
21313 return qe_invalid;
21314 6 }
21315
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(s_version > 34)
21316 {
21317 uint32_t num_used_mapscr_data;
21318 if(!p_igetl(&num_used_mapscr_data,f))
21319 return qe_invalid;
21320 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
21321 {
21322 uint32_t sz;
21323 if(!p_igetl(&sz,f))
21324 return qe_invalid;
21325 temp_zinit.screen_data[q].resize(sz);
21326 if(sz)
21327 {
21328 std::vector<int32_t> dummy;
21329 if(!p_getlvec(&dummy,f))
21330 return qe_invalid;
21331 temp_zinit.screen_data[q] = dummy;
21332 }
21333 }
21334 }
21335
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if (s_version > 35)
21336 if(!p_igetzf(&temp_zinit.shove_offset,f))
21337 return qe_invalid;
21338
21339 299 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
21340 299 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
21341
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 110 times.
299 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
21342 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
21343
21344 299 return 0;
21345 299 }
21346 497 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
21347 {
21348 497 zinitdata temp_zinit = {};
21349
21350
3/4
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
497 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
21351
21352 int32_t dummy;
21353 497 word s_version=0;
21354 byte padding;
21355
21356
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 23 times.
497 if(Header->zelda_version > 0x192)
21357 {
21358
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&s_version,f))
21359 return qe_invalid;
21360
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (s_version > V_INITDATA)
21361 return qe_version;
21362 474 FFCore.quest_format[vInitData] = s_version;
21363
21364
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
474 if(!read_deprecated_section_cversion(f))
21365 return qe_invalid;
21366
21367 //section size
21368
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetl(&dummy,f))
21369 return qe_invalid;
21370 474 }
21371
21372
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 198 times.
497 if(s_version < 37)
21373 {
21374
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
21375 return ret;
21376 299 }
21377 else
21378 {
21379 198 subscr_mode = ssdtMAX;
21380
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 198 times.
6534 for(int q = 0; q < MAXITEMS/8; ++q)
21381
2/4
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6336 times.
6336 if(!p_getc(&temp_zinit.items[q], f))
21382 return qe_invalid;
21383
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 29 times.
198 if(s_version >= 42)
21384 {
21385
2/2
✓ Branch 0 taken 86528 times.
✓ Branch 1 taken 169 times.
86697 for(int q = 0; q < MAXLEVELS; ++q)
21386 {
21387
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 78336 times.
86528 if (s_version >= 44)
21388 {
21389
2/4
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78336 times.
78336 if(!p_igetw(&temp_zinit.litems[q], f))
21390 return qe_invalid;
21391 78336 }
21392 else
21393 {
21394
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8192 times.
8192 if(!p_getc(&padding, f))
21395 return qe_invalid;
21396 8192 temp_zinit.litems[q] = word(padding);
21397 }
21398 86528 }
21399 169 }
21400 else
21401 {
21402 byte tmp_map[MAXLEVELS/8];
21403 byte tmp_compass[MAXLEVELS/8];
21404 byte tmp_boss_key[MAXLEVELS/8];
21405 byte tmp_mcguffin[MAXLEVELS/8];
21406
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 29 times.
1885 for(int q = 0; q < MAXLEVELS/8; ++q)
21407 {
21408
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1856 times.
✗ Branch 3 not taken.
1856 if(!p_getc(&tmp_map[q], f))
21409 return qe_invalid;
21410
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1856 times.
1856 if(!p_getc(&tmp_compass[q], f))
21411 return qe_invalid;
21412
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1856 times.
1856 if(!p_getc(&tmp_boss_key[q], f))
21413 return qe_invalid;
21414
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1856 times.
✗ Branch 3 not taken.
1856 if(!p_getc(&tmp_mcguffin[q], f))
21415 return qe_invalid;
21416 1856 }
21417
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 29 times.
14877 for(int q = 0; q < MAXLEVELS; ++q)
21418 {
21419
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
21420
3/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 14828 times.
14848 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
21421
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14848 times.
14848 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
21422
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 SETFLAG(temp_zinit.litems[q], (1 << li_mcguffin), get_bit(tmp_mcguffin, q));
21423 14848 }
21424 }
21425
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbvec(&temp_zinit.level_keys, f))
21426 return qe_invalid;
21427 byte num_counters;
21428
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&num_counters,f))
21429 return qe_invalid;
21430
2/2
✓ Branch 0 taken 21186 times.
✓ Branch 1 taken 198 times.
21384 for(int q = 0; q < num_counters; ++q)
21431
2/4
✓ Branch 0 taken 21186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21186 times.
21186 if(!p_igetw(&temp_zinit.counter[q],f))
21432 return qe_invalid;
21433
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 21186 times.
21384 for(int q = 0; q < num_counters; ++q)
21434
2/4
✓ Branch 0 taken 21186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21186 times.
21186 if(!p_igetw(&temp_zinit.mcounter[q],f))
21435 return qe_invalid;
21436
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.bomb_ratio,f))
21437 return qe_invalid;
21438
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hcp,f))
21439 return qe_invalid;
21440
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hcp_per_hc,f))
21441 return qe_invalid;
21442
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_igetw(&temp_zinit.cont_heart,f))
21443 return qe_invalid;
21444
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hp_per_heart,f))
21445 return qe_invalid;
21446
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_getc(&temp_zinit.magic_per_block,f))
21447 return qe_invalid;
21448
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21449 return qe_invalid;
21450
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21451 return qe_invalid;
21452
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.dither_type,f))
21453 return qe_invalid;
21454
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.dither_arg,f))
21455 return qe_invalid;
21456
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_getc(&temp_zinit.dither_percent,f))
21457 return qe_invalid;
21458
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.def_lightrad,f))
21459 return qe_invalid;
21460
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.transdark_percent,f))
21461 return qe_invalid;
21462
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.darkcol,f))
21463 return qe_invalid;
21464
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_grid_x,f))
21465 return qe_invalid;
21466
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_grid_y,f))
21467 return qe_invalid;
21468
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
21469 return qe_invalid;
21470
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
21471 return qe_invalid;
21472
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_grid_color,f))
21473 return qe_invalid;
21474
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
21475 return qe_invalid;
21476
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
21477 return qe_invalid;
21478
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.ss_flags,f))
21479 return qe_invalid;
21480
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbitstr(&temp_zinit.flags,f))
21481 return qe_invalid;
21482
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_getc(&temp_zinit.last_map,f))
21483 return qe_invalid;
21484
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.last_screen,f))
21485 return qe_invalid;
21486
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.msg_more_x,f))
21487 return qe_invalid;
21488
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.msg_more_y,f))
21489 return qe_invalid;
21490
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
21491 return qe_invalid;
21492
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.msg_speed,f))
21493 return qe_invalid;
21494
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.gravity,f))
21495 return qe_invalid;
21496
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.swimgravity,f))
21497 return qe_invalid;
21498
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.terminalv,f))
21499 return qe_invalid;
21500
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hero_swim_speed,f))
21501 return qe_invalid;
21502
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21503 return qe_invalid;
21504
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.hero_swim_div,f))
21505 return qe_invalid;
21506
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21507 return qe_invalid;
21508
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21509 return qe_invalid;
21510
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21511 return qe_invalid;
21512
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21513 return qe_invalid;
21514
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.heroStep,f))
21515 return qe_invalid;
21516
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
21517 return qe_invalid;
21518
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
21519 return qe_invalid;
21520
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21521 return qe_invalid;
21522
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.start_dmap,f))
21523 return qe_invalid;
21524
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&temp_zinit.subscrSpeed,f))
21525 return qe_invalid;
21526
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.switchhookstyle,f))
21527 return qe_invalid;
21528
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&temp_zinit.magicdrainrate,f))
21529 return qe_invalid;
21530
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetzf(&temp_zinit.shove_offset,f))
21531 return qe_invalid;
21532
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
21533 return qe_invalid;
21534
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbmap(&temp_zinit.gen_exitState, f))
21535 return qe_invalid;
21536
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
21537 return qe_invalid;
21538
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
198 if(!p_getbmap(&temp_zinit.gen_initd, f))
21539 return qe_invalid;
21540
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
21541 return qe_invalid;
21542
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbmap(&temp_zinit.gen_data, f))
21543 return qe_invalid;
21544
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getbmap(&temp_zinit.screen_data, f))
21545 return qe_invalid;
21546
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (s_version >= 38)
21547 {
21548
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
21549 return qe_invalid;
21550
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if (!p_getc(&temp_zinit.spriteflickercolor, f))
21551 return qe_invalid;
21552
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if (!p_getc(&temp_zinit.spriteflickertransp, f))
21553 return qe_invalid;
21554 198 }
21555
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 29 times.
198 if(s_version >= 39)
21556
2/4
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 169 times.
✗ Branch 3 not taken.
169 if(!p_igetzf(&temp_zinit.air_drag, f))
21557 return qe_invalid;
21558
21559 // TODO: this first branch can likely be removed, as it only fixes an issues
21560 // that existed for a handful of temporary z3 builds (and active users of that
21561 // fork would have been updating often, beyond s_version 40).
21562
3/4
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 169 times.
198 if (Header->is_z3 && s_version == 40)
21563 {
21564 if(!p_getc(&temp_zinit.region_mapping, f))
21565 return qe_invalid;
21566 }
21567 else
21568 {
21569
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 29 times.
198 if(s_version >= 40)
21570 {
21571
2/4
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 169 times.
✗ Branch 3 not taken.
169 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21572 return qe_invalid;
21573
2/4
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 169 times.
✗ Branch 3 not taken.
169 if(!p_igetw(&temp_zinit.light_wave_size, f))
21574 return qe_invalid;
21575 169 }
21576
21577
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 29 times.
198 if(s_version >= 41)
21578 {
21579
2/4
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 169 times.
✗ Branch 3 not taken.
169 if(!p_getc(&temp_zinit.region_mapping, f))
21580 return qe_invalid;
21581 169 }
21582 }
21583
21584
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 163 times.
198 if(s_version >= 43)
21585
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 163 times.
41891 for(uint q = 0; q < NUM_BOTTLE_SLOTS; ++q)
21586
2/4
✓ Branch 0 taken 41728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41728 times.
✗ Branch 3 not taken.
41728 if (!p_getc(&temp_zinit.bottle_slot[q], f))
21587 163 return qe_invalid;
21588
21589
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 45 times.
198 if(s_version >= 44)
21590
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if (!p_getbvec(&temp_zinit.lvlswitches, f))
21591 return qe_invalid;
21592
21593
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 45 times.
198 if (s_version >= 45)
21594 {
21595
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if (!p_igetw(&temp_zinit.item_spawn_flicker, f))
21596 return qe_invalid;
21597
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if (!p_igetw(&temp_zinit.item_timeout_dur, f))
21598 return qe_invalid;
21599
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if (!p_igetw(&temp_zinit.item_timeout_flicker, f))
21600 return qe_invalid;
21601
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if (!p_getc(&temp_zinit.item_flicker_speed, f))
21602 return qe_invalid;
21603 153 }
21604
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 153 times.
198 if(s_version >= 46)
21605 {
21606
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 153 times.
918 for(int q = 0; q < SPRITE_THRESHOLD_MAX; ++q)
21607
2/4
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
765 if(!p_igetw(&temp_zinit.sprite_z_thresholds[q], f))
21608 return qe_invalid;
21609 153 }
21610 }
21611
21612
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 344 times.
497 if(s_version < 46)
21613 {
21614 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_GROUND] = temp_zinit.jump_hero_layer_threshold;
21615 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_3] = temp_zinit.jump_hero_layer_threshold;
21616 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_4] = temp_zinit.jump_hero_layer_threshold;
21617 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_OVERHEAD] = word(-1);
21618 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_5] = word(-1);
21619 344 }
21620
21621
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 if (should_skip)
21622 return 0;
21623
21624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if(loading_tileset_flags & TILESET_CLEARMAPS)
21625 {
21626 temp_zinit.last_map = 0;
21627 temp_zinit.last_screen = 0;
21628 temp_zinit.screen_data.clear();
21629 }
21630
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 temp_zinit.normalize();
21631
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 zinit = temp_zinit;
21632
21633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497 times.
497 if(zinit.heroAnimationStyle==las_zelda3slow)
21634 {
21635 hero_animation_speed=2;
21636 }
21637 else
21638 {
21639 497 hero_animation_speed=1;
21640 }
21641
21642 497 return 0;
21643 497 }
21644
21645 /*
21646 void setupitemdropsets()
21647 {
21648 for(int32_t i=0; i<isMAX; i++)
21649 {
21650 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21651 }
21652 }
21653 */
21654
21655 438 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21656 {
21657
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 23 times.
438 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21658
21659 dword dummy_dword;
21660 438 word item_drop_sets_to_read=0;
21661 item_drop_object tempitemdrop;
21662 438 word s_version=0;
21663
21664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 438 times.
438 if (!should_skip)
21665
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21666 {
21667 112128 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21668 112566 }
21669
21670
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 23 times.
438 if(version > 0x192)
21671 {
21672 415 item_drop_sets_to_read=0;
21673
21674 //section version info
21675
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetw(&s_version,f))
21676 {
21677 return qe_invalid;
21678 }
21679
21680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (s_version > V_ITEMDROPSETS)
21681 return qe_version;
21682
21683 415 FFCore.quest_format[vItemDropsets] = s_version;
21684
21685
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!read_deprecated_section_cversion(f))
21686 {
21687 return qe_invalid;
21688 }
21689
21690 //section size
21691
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy_dword,f))
21692 {
21693 return qe_invalid;
21694 }
21695
21696 //finally... section data
21697
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetw(&item_drop_sets_to_read,f))
21698 {
21699 return qe_invalid;
21700 }
21701
21702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21703 {
21704 return qe_invalid;
21705 }
21706 415 }
21707 else
21708 {
21709 23 init_item_drop_sets();
21710 }
21711
21712
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 415 times.
438 if(s_version>=1)
21713 {
21714
2/2
✓ Branch 0 taken 6388 times.
✓ Branch 1 taken 415 times.
6803 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21715 {
21716
1/2
✓ Branch 0 taken 6388 times.
✗ Branch 1 not taken.
6388 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21717 {
21718 return qe_invalid;
21719 }
21720
21721
2/2
✓ Branch 0 taken 63880 times.
✓ Branch 1 taken 6388 times.
70268 for(int32_t j=0; j<10; ++j)
21722 {
21723
1/2
✓ Branch 0 taken 63880 times.
✗ Branch 1 not taken.
63880 if(!p_igetw(&tempitemdrop.item[j],f))
21724 {
21725 return qe_invalid;
21726 }
21727 63880 }
21728
21729
2/2
✓ Branch 0 taken 70268 times.
✓ Branch 1 taken 6388 times.
76656 for(int32_t j=0; j<11; ++j)
21730 {
21731
1/2
✓ Branch 0 taken 70268 times.
✗ Branch 1 not taken.
70268 if(!p_igetw(&tempitemdrop.chance[j],f))
21732 {
21733 return qe_invalid;
21734 }
21735 70268 }
21736
21737 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21738 // overrides the quest's set #12.
21739
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6388 if(s_version<2 && i==12)
21740 continue;
21741
21742 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21743
1/4
✓ Branch 0 taken 6388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6388 if(s_version<2) for(int32_t j=0; j<10; ++j)
21744 {
21745 int32_t it = tempitemdrop.item[j];
21746
21747 if((itemsbuf[it].type == itype_rupee
21748 && ((itemsbuf[it].amount)&0xFFF) == 10)
21749 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21750 {
21751 tempitemdrop.chance[j+1]=0;
21752 }
21753 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21754 {
21755 tempitemdrop.chance[j+1]=0;
21756 }
21757
21758 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21759 if(itemsbuf[it].type == itype_misc)
21760 {
21761 // If a non-gameplay item was selected, then item drop was aborted.
21762 // Reflect this by increasing the 'Nothing' chance accordingly.
21763 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21764 tempitemdrop.chance[j+1]=0;
21765 }
21766 }
21767
21768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6388 times.
6388 if (!should_skip)
21769 6388 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21770 6388 }
21771 415 }
21772
21773 438 return 0;
21774 438 }
21775
21776 415 int32_t readfavorites(PACKFILE *f, int32_t)
21777 {
21778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21779
21780 int32_t temp_num;
21781 dword dummy_dword;
21782 word num_favorite_combos;
21783 word num_favorite_combo_aliases;
21784 415 word s_version=0;
21785
21786 //section version info
21787
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetw(&s_version,f))
21788 {
21789 return qe_invalid;
21790 }
21791
21792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (s_version > V_FAVORITES)
21793 return qe_version;
21794
21795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (!should_skip)
21796 415 FFCore.quest_format[vFavourites] = s_version;
21797
21798
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!read_deprecated_section_cversion(f))
21799 {
21800 return qe_invalid;
21801 }
21802
21803 //section size
21804
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetl(&dummy_dword,f))
21805 {
21806 return qe_invalid;
21807 }
21808
21809 415 word per_row = FAVORITECOMBO_PER_ROW;
21810 415 word per_page = FAVORITECOMBO_PER_PAGE;
21811
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 204 times.
415 if(s_version >= 3)
21812
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&per_row,f))
21813 return qe_invalid;
21814
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 198 times.
415 if(s_version >= 4)
21815
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetw(&per_page,f))
21816 return qe_invalid;
21817 //finally... section data
21818
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 if(!p_igetw(&num_favorite_combos,f))
21819 {
21820 return qe_invalid;
21821 }
21822
21823 //Hack; port old favorite combos
21824
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
415 if(s_version < 3 && num_favorite_combos == 100)
21825 211 per_row = 13;
21826
21827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (!should_skip)
21828
2/2
✓ Branch 0 taken 522900 times.
✓ Branch 1 taken 415 times.
523315 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21829 523315 favorite_combos[q] = -1;
21830 415 byte favtype = 0;
21831
2/2
✓ Branch 0 taken 28021 times.
✓ Branch 1 taken 415 times.
28436 for(int32_t i=0; i<num_favorite_combos; i++)
21832 {
21833
2/2
✓ Branch 0 taken 6915 times.
✓ Branch 1 taken 21106 times.
28021 if (s_version >= 4)
21834 {
21835
1/2
✓ Branch 0 taken 6915 times.
✗ Branch 1 not taken.
6915 if (!p_getc(&favtype, f))
21836 {
21837 return qe_invalid;
21838 }
21839 6915 }
21840 else
21841 21106 favtype = 0;
21842
1/2
✓ Branch 0 taken 28021 times.
✗ Branch 1 not taken.
28021 if(!p_igetl(&temp_num,f))
21843 {
21844 return qe_invalid;
21845 }
21846
21847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28021 times.
28021 if (should_skip)
21848 continue;
21849
21850
2/2
✓ Branch 0 taken 6915 times.
✓ Branch 1 taken 21106 times.
28021 if(per_row == FAVORITECOMBO_PER_ROW)
21851 {
21852 6915 favorite_combos[i] = temp_num;
21853 6915 favorite_combo_modes[i] = favtype;
21854 6915 }
21855 else
21856 {
21857 21106 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21858 21106 favorite_combos[new_i]=temp_num;
21859 21106 favorite_combo_modes[new_i] = favtype;
21860 }
21861 28021 }
21862
21863 // Discard the separate favorite aliases list from previous versions
21864
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 217 times.
415 if(s_version<4)
21865 {
21866
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (!p_igetw(&num_favorite_combo_aliases, f))
21867 {
21868 return qe_invalid;
21869 }
21870
21871
2/2
✓ Branch 0 taken 21100 times.
✓ Branch 1 taken 217 times.
21317 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21872 {
21873
1/2
✓ Branch 0 taken 21100 times.
✗ Branch 1 not taken.
21100 if (!p_igetl(&temp_num, f))
21874 {
21875 return qe_invalid;
21876 }
21877 21100 }
21878 217 }
21879
21880 415 word max_combo_cols = 0;
21881 415 word max_mappages = 0;
21882
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 204 times.
415 if(s_version >= 2)
21883 {
21884
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&max_combo_cols,f))
21885 return qe_invalid;
21886 204 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21887
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int q = 0; q < max_combo_cols; ++q)
21888 {
21889
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetl(&tmp,f))
21890 return qe_invalid;
21891
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetl(&tmp2,f))
21892 return qe_invalid;
21893
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetl(&tmp3,f))
21894 return qe_invalid;
21895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816 times.
816 if(q < MAX_COMBO_COLS)
21896 {
21897 816 First[q] = tmp;
21898 816 combo_alistpos[q] = tmp2;
21899 816 combo_pool_listpos[q] = tmp3;
21900 816 }
21901 816 }
21902
21903
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&max_mappages,f))
21904 return qe_invalid;
21905
2/2
✓ Branch 0 taken 1836 times.
✓ Branch 1 taken 204 times.
2040 for(int q = 0; q < max_mappages; ++q)
21906 {
21907
1/2
✓ Branch 0 taken 1836 times.
✗ Branch 1 not taken.
1836 if(!p_igetl(&tmp,f))
21908 return qe_invalid;
21909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1836 times.
1836 if(!p_igetl(&tmp2,f))
21910 return qe_invalid;
21911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1836 times.
1836 if(q < MAX_MAPPAGE_BTNS)
21912 {
21913 1836 map_page[q].map = tmp;
21914 1836 map_page[q].screen = tmp2;
21915 1836 }
21916 1836 }
21917 204 }
21918
21919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if (should_skip)
21920 return 0;
21921
21922
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 415 times.
1259 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21923 {
21924 844 First[q] = 0;
21925 844 combo_alistpos[q] = 0;
21926 844 combo_pool_listpos[q] = 0;
21927 844 }
21928
2/2
✓ Branch 0 taken 1899 times.
✓ Branch 1 taken 415 times.
2314 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21929 {
21930 1899 map_page[q].map = 0;
21931 1899 map_page[q].screen = 0;
21932 1899 }
21933
21934 415 return 0;
21935 415 }
21936
21937 132 int32_t read_adv_music(PACKFILE *f)
21938 {
21939 132 word s_version = 0;
21940 dword section_size;
21941
21942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_igetw(&s_version,f))
21943 return qe_invalid;
21944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if (s_version > V_ADVMUSIC)
21945 return qe_version;
21946
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!read_deprecated_section_cversion(f))
21947 return qe_invalid;
21948
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetl(&section_size,f))
21949 return qe_invalid;
21950
21951 132 word count = 0;
21952
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if (!p_igetw(&count, f))
21953 return qe_invalid;
21954
21955 132 quest_music.clear();
21956
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 132 times.
398 for (size_t q = 0; q < count; ++q)
21957 {
21958 266 AdvancedMusic& m = quest_music.emplace_back();
21959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266 times.
266 if (auto ret = m.read(f, s_version))
21960 return ret;
21961 266 m.id = q + 1;
21962 266 }
21963 132 return 0;
21964 132 }
21965
21966 /*
21967 switch (ret) {
21968 case 0:
21969 break;
21970
21971 case qe_invalid:
21972 goto invalid;
21973 break;
21974 default:
21975 pack_fclose(f);
21976 if(!oldquest)
21977 delete_file(tmpfilename);
21978 return ret;
21979 break;
21980 }
21981 */
21982
21983 const char *skip_text[skip_max]=
21984 {
21985 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21986 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21987 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21988 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21989 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21990 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21991 "skip_favorites", "skip_zinfo", "skip_adv_music"
21992 };
21993
21994
21995 void port250QuestRules(){
21996
21997 portCandleRules(); //Candle
21998 portBombRules();
21999
22000 }
22001
22002 void portCandleRules()
22003 {
22004 bool hurtshero = get_qr(qr_FIREPROOFHERO);
22005 //itemdata itemsbuf;
22006 for ( int32_t q = 0; q < MAXITEMS; q++ )
22007 {
22008 if ( itemsbuf[q].type == itype_candle )
22009 {
22010 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
22011 else itemsbuf[q].flags &= ~ item_flag2;
22012 }
22013 }
22014 }
22015
22016 void portBombRules()
22017 {
22018 bool hurtshero = get_qr(qr_OUCHBOMBS);
22019 //itemdata itemsbuf;
22020 for ( int32_t q = 0; q < MAXITEMS; q++ )
22021 {
22022 if ( itemsbuf[q].type == itype_bomb )
22023 {
22024 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
22025 else itemsbuf[q].flags &= ~ item_flag2;
22026 }
22027 }
22028 }
22029
22030 19401 static int section_id_to_enum(int id)
22031 {
22032
25/28
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✓ Branch 3 taken 832 times.
✓ Branch 4 taken 832 times.
✓ Branch 5 taken 832 times.
✓ Branch 6 taken 832 times.
✓ Branch 7 taken 749 times.
✓ Branch 8 taken 832 times.
✓ Branch 9 taken 832 times.
✓ Branch 10 taken 832 times.
✓ Branch 11 taken 832 times.
✓ Branch 12 taken 832 times.
✓ Branch 13 taken 832 times.
✓ Branch 14 taken 749 times.
✓ Branch 15 taken 749 times.
✓ Branch 16 taken 832 times.
✓ Branch 17 taken 832 times.
✓ Branch 18 taken 773 times.
✓ Branch 19 taken 749 times.
✓ Branch 20 taken 749 times.
✓ Branch 21 taken 749 times.
✓ Branch 22 taken 832 times.
✓ Branch 23 taken 832 times.
✓ Branch 24 taken 773 times.
✓ Branch 25 taken 749 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 132 times.
19401 switch (id)
22033 {
22034 case ID_HEADER: return skip_header;
22035 832 case ID_RULES: return skip_rules;
22036 832 case ID_STRINGS: return skip_strings;
22037 832 case ID_MISC: return skip_misc;
22038 832 case ID_TILES: return skip_tiles;
22039 832 case ID_COMBOS: return skip_combos;
22040 749 case ID_COMBOALIASES: return skip_comboaliases;
22041 832 case ID_CSETS: return skip_csets;
22042 832 case ID_MAPS: return skip_maps;
22043 832 case ID_DMAPS: return skip_dmaps;
22044 832 case ID_DOORS: return skip_doors;
22045 832 case ID_ITEMS: return skip_items;
22046 832 case ID_WEAPONS: return skip_weapons;
22047 749 case ID_COLORS: return skip_colors;
22048 749 case ID_ICONS: return skip_icons;
22049 832 case ID_INITDATA: return skip_initdata;
22050 832 case ID_GUYS: return skip_guys;
22051 773 case ID_HEROSPRITES: return skip_herosprites;
22052 749 case ID_SUBSCREEN: return skip_subscreens;
22053 749 case ID_FFSCRIPT: return skip_ffscript;
22054 749 case ID_SFX: return skip_sfx;
22055 832 case ID_MIDIS: return skip_midis;
22056 832 case ID_CHEATS: return skip_cheats;
22057 773 case ID_ITEMDROPSETS: return skip_itemdropsets;
22058 749 case ID_FAVORITES: return skip_favorites;
22059 case ID_ZINFO: return skip_zinfo;
22060 132 case ID_ADVMUSIC: return skip_adv_music;
22061 }
22062
22063 return -1;
22064 19401 }
22065
22066 18993 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
22067 {
22068 18993 int section_enum = section_id_to_enum(section_id);
22069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18993 times.
18993 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22070
2/2
✓ Branch 0 taken 7014 times.
✓ Branch 1 taken 11979 times.
18993 if (skip)
22071 {
22072 word s_version;
22073
1/2
✓ Branch 0 taken 7014 times.
✗ Branch 1 not taken.
7014 if (!p_igetw(&s_version,f))
22074 {
22075 return qe_invalid;
22076 }
22077
22078
1/2
✓ Branch 0 taken 7014 times.
✗ Branch 1 not taken.
7014 if (!read_deprecated_section_cversion(f))
22079 {
22080 return qe_invalid;
22081 }
22082
22083
3/4
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 6680 times.
✓ Branch 2 taken 334 times.
✗ Branch 3 not taken.
7014 if (section_id == ID_RULES && s_version > 16)
22084 {
22085 dword dummy;
22086 if (!p_igetl(&dummy,f))
22087 {
22088 return qe_invalid;
22089 }
22090 }
22091
22092
3/4
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 6680 times.
✓ Branch 2 taken 334 times.
✗ Branch 3 not taken.
7014 if (section_id == ID_FFSCRIPT && s_version >= 18)
22093 {
22094 word dummy;
22095 if (!p_igetw(&dummy,f))
22096 {
22097 return qe_invalid;
22098 }
22099 }
22100
22101 dword section_length;
22102
1/2
✓ Branch 0 taken 7014 times.
✗ Branch 1 not taken.
7014 if (!p_igetl(&section_length,f))
22103 {
22104 return qe_invalid;
22105 }
22106
22107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7014 times.
7014 if (pack_fseek(f, section_length))
22108 {
22109 return qe_invalid;
22110 }
22111
22112
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 6680 times.
7014 if (!pack_feof(f))
22113 {
22114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6680 times.
6680 if (!p_mgetl(&section_id,f))
22115 {
22116 return qe_invalid;
22117 }
22118 6680 }
22119
22120 7014 return qe_cancel;
22121 }
22122
22123 11979 return qe_OK;
22124 18993 }
22125
22126 // TODO: this was copied from zc/zasm_utils.cpp
22127 283 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
22128 {
22129 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
22130
22131 283 std::vector<zasm_script*> scripts;
22132
1/2
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
283 scripts.reserve(zasm_scripts.size());
22133
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 305182 times.
305465 for (auto& script : zasm_scripts)
22134
2/2
✓ Branch 0 taken 296700 times.
✓ Branch 1 taken 8482 times.
305182 if (script->valid())
22135
1/2
✓ Branch 0 taken 8482 times.
✗ Branch 1 not taken.
8482 scripts.push_back(script.get());
22136
22137
2/4
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 283 times.
✗ Branch 3 not taken.
283 std::for_each(scripts.begin(), scripts.end(), fn);
22138 283 }
22139
22140 497 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
22141 {
22142 // 2.55.9 or newer?
22143
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 327 times.
497 if (header.compareVer(2, 55, 9) >= 0)
22144 170 return false; // defer to whatever was set
22145
22146 // Replays created in 2.55 for quests prior to 2.55.9 should continue hiding the bottom pixels.
22147
12/18
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 277 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 277 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 277 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 277 times.
✓ Branch 10 taken 50 times.
✓ Branch 11 taken 277 times.
✓ Branch 12 taken 38 times.
✓ Branch 13 taken 289 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
327 if (replay_is_replaying() && replay_get_meta_str("zc_version_created").starts_with("2.55"))
22148 38 return true;
22149
22150 // Quests prior to 2.55.9 with a scripted subscreen?
22151
2/2
✓ Branch 0 taken 146435 times.
✓ Branch 1 taken 286 times.
146721 for (int i = 0; i < MAXDMAPS; i++)
22152 {
22153 146435 int script = DMaps[i].active_sub_script;
22154
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 146432 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
146435 if (script && dmapscripts[script] && dmapscripts[script]->valid())
22155 3 return true;
22156 146432 }
22157
22158 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
22159
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 std::string title = header.title;
22160
3/4
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 283 times.
286 if (title == "Yuurand: Tales of the Labyrinth")
22161 3 return true;
22162
22163 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
22164 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
22165 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
22166 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
22167 283 bool found = false;
22168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 283 times.
8765 _zasm_for_every_script([&](auto script){
22169
2/2
✓ Branch 0 taken 3033 times.
✓ Branch 1 taken 5449 times.
8482 if (found) return;
22170
22171
2/2
✓ Branch 0 taken 5419 times.
✓ Branch 1 taken 23840130 times.
23845549 for (const auto& instr : script->zasm)
22172 {
22173
4/4
✓ Branch 0 taken 20882211 times.
✓ Branch 1 taken 2957919 times.
✓ Branch 2 taken 358211 times.
✓ Branch 3 taken 20524000 times.
23840130 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
22174
22175 3316130 int value = instr.arg2;
22176
9/10
✓ Branch 0 taken 3316128 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3316125 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3316101 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3316101 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3316100 times.
3316130 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
22177 {
22178 30 found = true;
22179 30 break;
22180 }
22181 }
22182 8482 });
22183
22184 283 return found;
22185 497 }
22186
22187 static int32_t prev_quest_format[versiontypesLAST];
22188 static byte prev_quest_rules[QUESTRULES_NEW_SIZE];
22189 static byte prev_extra_rules[EXTRARULES_SIZE];
22190 static word prev_map_count;
22191
22192 // When skipping any section, we are loading a qst file just to poke at a couple things.
22193 // We should not mutate important globals in that case.
22194 // We should also restore these globals when loading a qst fails.
22195 // Globals that are read by usecases of `skip_flags` will have to be restored manually by the caller
22196 // (see load_imagebuf).
22197 832 static void store_prev_qstload_global_state()
22198 {
22199 832 memcpy(prev_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
22200 832 memcpy(prev_extra_rules, extra_rules, EXTRARULES_SIZE);
22201 832 memcpy(prev_quest_format, FFCore.quest_format, versiontypesLAST);
22202 832 prev_map_count = map_count;
22203 832 }
22204
22205 335 static void restore_prev_qstload_global_state()
22206 {
22207 335 memcpy(quest_rules, prev_quest_rules, QUESTRULES_NEW_SIZE);
22208 335 memcpy(extra_rules, prev_extra_rules, EXTRARULES_SIZE);
22209 335 unpack_qrs();
22210 335 memcpy(FFCore.quest_format, prev_quest_format, versiontypesLAST);
22211 335 map_count = prev_map_count;
22212 335 }
22213
22214 //Internal function for loadquest wrapper
22215 // TODO: refactor to never mutate global state, to make loading partial qst files easier and less error prone. huge project.
22216 832 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
22217 {
22218 832 DMapEditorLastMaptileUsed = 0;
22219 832 combosread=false;
22220 832 mapsread=false;
22221 832 fixffcs=false;
22222
22223 832 store_prev_qstload_global_state();
22224
22225 832 bool skipping_any = false;
22226
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 832 times.
4160 for (int i = 0; i < 4; i++)
22227 3328 skipping_any |= skip_flags[i] ? true : false;
22228
22229 832 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
22230
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
22231 {
22232 set_bit(skip_flags, skip_ffscript, 1);
22233 setZScriptVersion(V_FFSCRIPT);
22234 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
22235 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
22236 do_clear_scripts = true;
22237 }
22238
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(loading_tileset_flags & TILESET_CLEARMAPS)
22239 {
22240 set_bit(skip_flags, skip_maps, 1);
22241 }
22242
22243 char tmpfilename[L_tmpnam];
22244 832 temp_name(tmpfilename);
22245 832 bool catchup=false;
22246 byte tempbyte;
22247
22248 // oldquest flag is set when an unencrypted qst file is suspected.
22249 832 bool oldquest = false;
22250 832 int32_t open_error=0;
22251 832 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
22252
22253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!f)
22254 {
22255 ASSERT(open_error != 0);
22256 return open_error;
22257 }
22258
22259 832 memset(quest_rules, 0, QUESTRULES_NEW_SIZE);
22260 832 memset(extra_rules, 0, EXTRARULES_SIZE);
22261 832 unpack_qrs();
22262
22263
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 497 times.
832 if (!get_bit(skip_flags, skip_maps))
22264 497 Regions = {};
22265
22266
3/4
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 497 times.
✓ Branch 2 taken 335 times.
✗ Branch 3 not taken.
1167 if (!(get_bit(skip_flags, skip_dmaps) &&
22267
1/2
✓ Branch 0 taken 335 times.
✗ Branch 1 not taken.
335 get_bit(skip_flags, skip_maps) &&
22268 335 get_bit(skip_flags, skip_adv_music)))
22269 497 quest_music.clear(); // dmaps/maps of old quests will create advanced music
22270
22271
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 497 times.
832 if(do_clear_scripts)
22272 {
22273 497 zScript.clear();
22274 497 globalmap.clear();
22275 497 genericmap.clear();
22276 497 ffcmap.clear();
22277 497 itemmap.clear();
22278 497 npcmap.clear();
22279 497 ewpnmap.clear();
22280 497 lwpnmap.clear();
22281 497 playermap.clear();
22282 497 dmapmap.clear();
22283 497 screenmap.clear();
22284 497 itemspritemap.clear();
22285 497 comboscriptmap.clear();
22286 497 subscreenmap.clear();
22287
22288
2/2
✓ Branch 0 taken 253967 times.
✓ Branch 1 taken 497 times.
254464 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
22289 {
22290 253967 ffcmap[i].clear();
22291 253967 }
22292
22293 497 globalmap[0].slotname = "Slot 1:";
22294 497 globalmap[0].scriptname = "~Init";
22295 497 globalmap[0].update();
22296
22297
2/2
✓ Branch 0 taken 3479 times.
✓ Branch 1 taken 497 times.
3976 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
22298 {
22299 3479 globalmap[i].clear();
22300 3479 }
22301
22302
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
22303 {
22304 126735 itemmap[i].clear();
22305 126735 }
22306
22307 //new script types -- prevent carrying over to a quest that you load after reading them
22308 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
22309
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
22310 {
22311 126735 npcmap[i].clear();
22312 126735 }
22313
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22314 {
22315 126735 lwpnmap[i].clear();
22316 126735 }
22317
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22318 {
22319 126735 ewpnmap[i].clear();
22320 126735 }
22321
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 497 times.
2485 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
22322 {
22323 1988 playermap[i].clear();
22324 1988 }
22325
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
22326 {
22327 126735 dmapmap[i].clear();
22328 126735 }
22329
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
22330 {
22331 126735 screenmap[i].clear();
22332 126735 }
22333
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
22334 {
22335 126735 itemspritemap[i].clear();
22336 126735 }
22337
2/2
✓ Branch 0 taken 253967 times.
✓ Branch 1 taken 497 times.
254464 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
22338 {
22339 253967 comboscriptmap[i].clear();
22340 253967 }
22341
2/2
✓ Branch 0 taken 253967 times.
✓ Branch 1 taken 497 times.
254464 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
22342 {
22343 253967 genericmap[i].clear();
22344 253967 }
22345
2/2
✓ Branch 0 taken 126735 times.
✓ Branch 1 taken 497 times.
127232 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
22346 {
22347 126735 subscreenmap[i].clear();
22348 126735 }
22349
22350 497 reset_scripts();
22351 497 }
22352
22353 832 zquestheader tempheader{};
22354
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 tempheader.filename = filename;
22355
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 zinfo tempzi;
22356
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 tempzi.clear();
22357 832 load_tmp_zi = &tempzi;
22358
22359 char zinfofilename[2048];
22360
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 replace_extension(zinfofilename, filename, "zinfo", 2047);
22361 832 int32_t ret=0;
22362
22363 //header
22364
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_out("Reading Header...");
22365
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 ret=readheader(f, &tempheader, printmetadata);
22366
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
832 checkstatus(ret);
22367
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_out("okay.");
22368
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_eol();
22369
22370
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 617 times.
832 if(read_zinfo)
22371 {
22372
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 box_out("Reading ZInfo - ");
22373
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 212 times.
✓ Branch 2 taken 215 times.
✗ Branch 3 not taken.
215 box_out(read_ext_zinfo ? "External..." : "Internal...");
22374
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 212 times.
215 if(read_ext_zinfo)
22375 {
22376
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
22377
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
22378
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
22379
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
22380 3 }
22381 else
22382 {
22383
1/2
✓ Branch 0 taken 212 times.
✗ Branch 1 not taken.
212 ret=readzinfo(f, tempzi, tempheader);
22384
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
212 checkstatus(ret);
22385 }
22386
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 box_out("okay.");
22387
1/2
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
215 box_eol();
22388 215 }
22389
22390
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 24 times.
832 if(tempheader.zelda_version>=0x193)
22391 {
22392 dword section_id;
22393
22394 //section id
22395
2/4
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✗ Branch 3 not taken.
808 if(!p_mgetl(&section_id,f))
22396 {
22397 goto invalid;
22398 }
22399
22400 808 std::set<dword> seen_sections;
22401
22402
3/4
✓ Branch 0 taken 19801 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18993 times.
✓ Branch 3 taken 808 times.
19801 while(!pack_feof(f))
22403 {
22404
2/4
✓ Branch 0 taken 18993 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18993 times.
✗ Branch 3 not taken.
18993 if (seen_sections.contains(section_id))
22405 goto invalid;
22406
1/2
✓ Branch 0 taken 18993 times.
✗ Branch 1 not taken.
18993 seen_sections.insert(section_id);
22407
22408
3/4
✓ Branch 0 taken 18993 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11979 times.
✓ Branch 3 taken 7014 times.
18993 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22409 {
22410
1/2
✓ Branch 0 taken 7014 times.
✗ Branch 1 not taken.
7014 if (retval == qe_cancel)
22411 7014 continue;
22412 checkstatus(retval);
22413 }
22414
22415
25/26
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 474 times.
✓ Branch 2 taken 808 times.
✓ Branch 3 taken 808 times.
✓ Branch 4 taken 474 times.
✓ Branch 5 taken 415 times.
✓ Branch 6 taken 808 times.
✓ Branch 7 taken 474 times.
✓ Branch 8 taken 474 times.
✓ Branch 9 taken 474 times.
✓ Branch 10 taken 474 times.
✓ Branch 11 taken 474 times.
✓ Branch 12 taken 415 times.
✓ Branch 13 taken 415 times.
✓ Branch 14 taken 474 times.
✓ Branch 15 taken 474 times.
✓ Branch 16 taken 415 times.
✓ Branch 17 taken 415 times.
✓ Branch 18 taken 415 times.
✓ Branch 19 taken 415 times.
✓ Branch 20 taken 474 times.
✓ Branch 21 taken 474 times.
✓ Branch 22 taken 415 times.
✓ Branch 23 taken 415 times.
✓ Branch 24 taken 132 times.
✗ Branch 25 not taken.
11979 switch(section_id)
22416 {
22417 case ID_RULES:
22418
22419 //rules
22420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22421 {
22422 box_out("found.");
22423 box_eol();
22424 catchup=false;
22425 }
22426
22427
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Rules...");
22428
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readrules(f, &tempheader);
22429
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22430
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22431
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22432 474 break;
22433
22434 case ID_STRINGS:
22435
22436 //strings
22437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22438 {
22439 box_out("found.");
22440 box_eol();
22441 catchup=false;
22442 }
22443
22444
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Strings...");
22445
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readstrings(f, &tempheader);
22446
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22447
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22448
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22449 474 break;
22450
22451 case ID_MISC:
22452
22453 //misc data
22454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(catchup)
22455 {
22456 box_out("found.");
22457 box_eol();
22458 catchup=false;
22459 }
22460
22461
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("Reading Misc. Data...");
22462
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 ret=readmisc(f, &tempheader, Misc);
22463
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
808 checkstatus(ret);
22464
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("okay.");
22465
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_eol();
22466 808 break;
22467
22468 case ID_TILES:
22469
22470 //tiles
22471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(catchup)
22472 {
22473 box_out("found.");
22474 box_eol();
22475 catchup=false;
22476 }
22477
22478
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("Reading Tiles...");
22479
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
22480
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
808 checkstatus(ret);
22481
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("okay.");
22482
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_eol();
22483 808 break;
22484
22485 case ID_COMBOS:
22486
22487 //combos
22488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22489 {
22490 box_out("found.");
22491 box_eol();
22492 catchup=false;
22493 }
22494
22495
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Combos...");
22496
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
22497 474 combosread=true;
22498
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22499
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22500
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22501 474 break;
22502
22503 case ID_COMBOALIASES:
22504
22505 //combo aliases
22506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22507 {
22508 box_out("found.");
22509 box_eol();
22510 catchup=false;
22511 }
22512
22513
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Combo Aliases...");
22514
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
22515
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22516
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22517
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22518 415 break;
22519
22520 case ID_CSETS:
22521
22522 //color data
22523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(catchup)
22524 {
22525 box_out("found.");
22526 box_eol();
22527 catchup=false;
22528 }
22529
22530
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("Reading Color Data...");
22531
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
22532
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
808 checkstatus(ret);
22533
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_out("okay.");
22534
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 box_eol();
22535 808 break;
22536
22537 case ID_MAPS:
22538
22539 //maps
22540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22541 {
22542 box_out("found.");
22543 box_eol();
22544 catchup=false;
22545 }
22546
22547
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Maps...");
22548
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readmaps(f, &tempheader);
22549 474 mapsread=true;
22550
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22551
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22552
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22553 474 break;
22554
22555 case ID_DMAPS:
22556
22557 //dmaps
22558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22559 {
22560 box_out("found.");
22561 box_eol();
22562 catchup=false;
22563 }
22564
22565
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading DMaps...");
22566
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
22567
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22568
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22569
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22570 474 break;
22571
22572 case ID_DOORS:
22573
22574 //door combo sets
22575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22576 {
22577 box_out("found.");
22578 box_eol();
22579 catchup=false;
22580 }
22581
22582
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Doors...");
22583
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readdoorcombosets(f, &tempheader);
22584
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22585
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22586
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22587 474 break;
22588
22589 case ID_ITEMS:
22590
22591 //items
22592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22593 {
22594 box_out("found.");
22595 box_eol();
22596 catchup=false;
22597 }
22598
22599
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Items...");
22600
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readitems(f, tempheader.zelda_version, tempheader.build);
22601
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22602
22603
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22604
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22605 474 break;
22606
22607 case ID_WEAPONS:
22608
22609 //weapons
22610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22611 {
22612 box_out("found.");
22613 box_eol();
22614 catchup=false;
22615 }
22616
22617
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Weapons...");
22618
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readweapons(f, &tempheader);
22619
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22620
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22621
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22622 474 break;
22623
22624 case ID_COLORS:
22625
22626 //misc. colors
22627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22628 {
22629 box_out("found.");
22630 box_eol();
22631 catchup=false;
22632 }
22633
22634
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Misc. Colors...");
22635
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readmisccolors(f, &tempheader, Misc);
22636
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22637
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22638
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22639 415 break;
22640
22641 case ID_ICONS:
22642
22643 //game icons
22644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22645 {
22646 box_out("found.");
22647 box_eol();
22648 catchup=false;
22649 }
22650
22651
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Game Icons...");
22652
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readgameicons(f, &tempheader, Misc);
22653
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22654
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22655
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22656 415 break;
22657
22658 case ID_INITDATA:
22659
22660 //initialization data
22661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22662 {
22663 box_out("found.");
22664 box_eol();
22665 catchup=false;
22666 }
22667
22668
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Init. Data...");
22669
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readinitdata(f, &tempheader);
22670
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22671
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22672
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22673
22674
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
474 if(!get_bit(skip_flags, skip_subscreens))
22675 {
22676
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 380 times.
474 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22677 {
22678
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 setupsubscreens();
22679
22680
2/2
✓ Branch 0 taken 48128 times.
✓ Branch 1 taken 94 times.
48222 for(int32_t i=0; i<MAXDMAPS; ++i)
22681 {
22682 48128 int32_t type=DMaps[i].type&dmfTYPE;
22683
2/2
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 47042 times.
48128 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22684 48128 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22685 48128 }
22686 94 }
22687 474 }
22688
22689
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
474 if(!get_bit(skip_flags, skip_sfx))
22690 {
22691 474 setupsfx();
22692 474 }
22693
22694
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!get_bit(skip_flags, skip_itemdropsets))
22695 {
22696
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 init_item_drop_sets();
22697 474 }
22698
22699
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
474 if(!get_bit(skip_flags, skip_favorites))
22700 {
22701 474 init_favorites();
22702 474 }
22703
22704 474 break;
22705
22706 case ID_GUYS:
22707
22708 //guys
22709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22710 {
22711 box_out("found.");
22712 box_eol();
22713 catchup=false;
22714 }
22715
22716
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Custom Guy Data...");
22717
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readguys(f, &tempheader);
22718
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22719
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22720
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22721 474 break;
22722
22723 case ID_HEROSPRITES:
22724
22725 //hero sprites
22726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22727 {
22728 box_out("found.");
22729 box_eol();
22730 catchup=false;
22731 }
22732
22733
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Custom Hero Sprite Data...");
22734
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readherosprites(f, &tempheader);
22735
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22736
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22737
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22738 415 break;
22739
22740 case ID_SUBSCREEN:
22741
22742 //custom subscreens
22743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22744 {
22745 box_out("found.");
22746 box_eol();
22747 catchup=false;
22748 }
22749
22750
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Custom Subscreen Data...");
22751
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readsubscreens(f);
22752
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22753
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22754
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22755 415 break;
22756
22757 case ID_FFSCRIPT:
22758
22759 //Freeform combo scripts
22760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22761 {
22762 box_out("found.");
22763 box_eol();
22764 catchup=false;
22765 }
22766
22767
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading FF Script Data...");
22768
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readffscript(f, &tempheader);
22769
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22770
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22771
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22772 415 break;
22773
22774 case ID_SFX:
22775
22776 //SFX data
22777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22778 {
22779 box_out("found.");
22780 box_eol();
22781 catchup=false;
22782 }
22783
22784
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading SFX Data...");
22785
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readsfx(f, &tempheader);
22786
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22787
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22788
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22789 415 break;
22790
22791 case ID_MIDIS:
22792
22793 //midis
22794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22795 {
22796 box_out("found.");
22797 box_eol();
22798 catchup=false;
22799 }
22800
22801
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading MIDIs...");
22802
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readmidis(f, &tempheader, tunes);
22803
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22804
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22805
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22806 474 break;
22807
22808 case ID_CHEATS:
22809
22810 //cheat codes
22811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(catchup)
22812 {
22813 box_out("found.");
22814 box_eol();
22815 catchup=false;
22816 }
22817
22818
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("Reading Cheat Codes...");
22819
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 ret=readcheatcodes(f, &tempheader);
22820
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
474 checkstatus(ret);
22821
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_out("okay.");
22822
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 box_eol();
22823 474 break;
22824
22825 case ID_ITEMDROPSETS:
22826
22827 //item drop sets
22828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22829 {
22830 box_out("found.");
22831 box_eol();
22832 catchup=false;
22833 }
22834
22835
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Item Drop Sets...");
22836
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readitemdropsets(f, tempheader.zelda_version);
22837
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22838
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22839
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22840 415 break;
22841
22842 case ID_FAVORITES:
22843
22844 //favorite combos and combo aliases
22845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
415 if(catchup)
22846 {
22847 box_out("found.");
22848 box_eol();
22849 catchup=false;
22850 }
22851
22852
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("Reading Favorite Combos...");
22853
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 ret=readfavorites(f, tempheader.zelda_version);
22854
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 415 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
415 checkstatus(ret);
22855
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_out("okay.");
22856
1/2
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
415 box_eol();
22857 415 break;
22858
22859 case ID_ADVMUSIC:
22860
22861 // advanced music
22862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(catchup)
22863 {
22864 box_out("found.");
22865 box_eol();
22866 catchup=false;
22867 }
22868
22869
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 box_out("Reading Advanced Music...");
22870
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 ret = read_adv_music(f);
22871
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
132 checkstatus(ret);
22872
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 box_out("okay.");
22873
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 box_eol();
22874 132 break;
22875
22876 default:
22877 if(!catchup)
22878 {
22879 box_out("Bad token! Searching...");
22880 box_eol();
22881 }
22882
22883 catchup=true;
22884 break;
22885 }
22886
22887
22888
1/2
✓ Branch 0 taken 11979 times.
✗ Branch 1 not taken.
11979 if(catchup)
22889 {
22890 //section id
22891 section_id=(section_id<<8);
22892
22893 if(!p_getc(&tempbyte,f))
22894 {
22895 goto invalid;
22896 }
22897
22898 section_id+=tempbyte;
22899 }
22900
22901 else
22902 {
22903 //section id
22904
3/4
✓ Branch 0 taken 11979 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11505 times.
✓ Branch 3 taken 474 times.
11979 if(!pack_feof(f))
22905 {
22906
2/4
✓ Branch 0 taken 11505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11505 times.
✗ Branch 3 not taken.
11505 if(!p_mgetl(&section_id,f))
22907 {
22908 goto invalid;
22909 }
22910 11505 }
22911 }
22912 }
22913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 }
22914 else
22915 {
22916
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22917
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22918
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22919
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22920
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22921
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22922
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22923
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22924
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22925
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22926
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22927
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22928
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22929
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "MIDIs", ID_MIDIS, [&](){ return readmidis(f, &tempheader, tunes); }},
22930
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22931
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22932
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22933
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22934 };
22935
22936 24 legacy_skip_flags = skip_flags;
22937
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22938 {
22939
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22940
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22941
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22942 {
22943 // Nothing to read.
22944
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22945 1 continue;
22946
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22947 1 continue;
22948
22949 // Haven't looked at how to skip these, because we don't need to currently: the only
22950 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22951
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22952 1 continue;
22953
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22954 1 continue;
22955
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22956 1 continue;
22957
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22958 1 continue;
22959
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22960 1 continue;
22961 9 }
22962
22963 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22964 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22965 // read all the sections even if requested to skip some.
22966 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22967 // {
22968 // if (retval == qe_cancel)
22969 // continue;
22970 // checkstatus(retval);
22971 // }
22972
22973
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22974
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22975
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22976
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22977
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22978 }
22979 24 legacy_skip_flags = nullptr;
22980
22981
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22982 {
22983
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22984
22985
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22986 {
22987 11776 int32_t type=DMaps[i].type&dmfTYPE;
22988
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22989 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22990 11776 }
22991 23 }
22992
22993
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22994
22995
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22996 23 setupsfx();
22997
22998
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22999 23 init_favorites();
23000
23001
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
23002
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
23003
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
23004
23005
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 init_spritelists();
23006
23007 // check data
23008
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(f)
23009 {
23010
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 pack_fclose(f);
23011 832 }
23012
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 clear_quest_tmpfile();
23013
23014
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!oldquest)
23015 {
23016
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 832 times.
832 if(exists(tmpfilename))
23017 {
23018 delete_file(tmpfilename);
23019 }
23020 832 }
23021
23022
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(fixffcs && combosread && mapsread)
23023 {
23024 for(int32_t i=0; i<map_count; i++)
23025 {
23026 for(int32_t j=0; j<MAPSCRS; j++)
23027 {
23028 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
23029 for(int32_t m=0; m<c; m++)
23030 {
23031 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
23032 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
23033 }
23034 }
23035 }
23036 }
23037
23038
3/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 335 times.
832 if (!get_bit(skip_flags, skip_rules))
23039 {
23040
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
23041
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
23042
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 423 times.
497 if (should_hide)
23043
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
23044
23045
3/4
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 328 times.
497 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
23046 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
23047 497 }
23048
23049
7/10
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 769 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
832 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
23050 {
23051
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 set_qr(qr_CONTFULL_DEP, 0);
23052
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 zinit.flags.set(INIT_FL_CONTPERCENT,true);
23053 62 zinit.cont_heart=100;
23054 62 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
23055 62 }
23056
23057
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_out("Done.");
23058
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_eol();
23059
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 box_end(false);
23060
23061
3/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 498 times.
✓ Branch 3 taken 334 times.
832 if(!get_bit(skip_flags, skip_header))
23062 {
23063
1/2
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
498 *Header = tempheader;
23064 498 }
23065
3/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 335 times.
832 if(!get_bit(skip_flags, skip_zinfo))
23066 {
23067
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 ZI.copyFrom(tempzi);
23068 497 }
23069
23070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(loading_tileset_flags & TILESET_CLEARMAPS)
23071 {
23072 TheMaps.clear();
23073 TheMaps.resize(MAPSCRS*1);
23074 map_count = 1;
23075 map_infos.clear();
23076 map_infos.resize(1);
23077 }
23078
23079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(loading_tileset_flags & TILESET_CLEARHEADER)
23080 {
23081 memset(Header->password, 0, sizeof(Header->password));
23082 memset(Header->minver, 0, sizeof(Header->minver));
23083 memset(Header->title, 0, sizeof(Header->title));
23084 memset(Header->author, 0, sizeof(Header->author));
23085 memset(Header->version, 0, sizeof(Header->version));
23086 Header->use_keyfile = 0;
23087 Header->dirty_password = false;
23088 cvs_MD5Context ctx;
23089 cvs_MD5Init(&ctx);
23090 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
23091 cvs_MD5Final(Header->pwd_hash, &ctx);
23092 }
23093
23094
3/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 335 times.
832 if (!get_bit(skip_flags, skip_maps))
23095 {
23096 // Not needed, so release its memory.
23097
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 old_combo_pages = {};
23098 497 }
23099
23100
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 497 times.
832 if (skipping_any)
23101
1/2
✓ Branch 0 taken 335 times.
✗ Branch 1 not taken.
335 restore_prev_qstload_global_state();
23102
23103 832 return qe_OK;
23104
23105 invalid:
23106 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
23107 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
23108 box_out("error.");
23109 box_eol();
23110 box_end(true);
23111
23112 pack_fclose(f);
23113
23114 if(!oldquest)
23115 {
23116 if(exists(tmpfilename))
23117 {
23118 delete_file(tmpfilename);
23119 }
23120 }
23121
23122 restore_prev_qstload_global_state();
23123
23124 return qe_invalid;
23125
23126 832 }
23127
23128 334 std::string get_last_loaded_qstpath()
23129 {
23130 334 return last_loaded_qstpath;
23131 }
23132
23133 832 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
23134 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
23135 bool report, byte qst_num, dword tilesetflags)
23136 {
23137 832 loading_tileset_flags = tilesetflags;
23138 832 const char* basename = get_filename(filename);
23139 832 zapp_reporting_add_breadcrumb("load_quest", basename);
23140 832 zapp_reporting_set_tag("qst.filename", basename);
23141
23142 832 last_loaded_qstpath = filename;
23143 832 loading_qst_name = filename;
23144 832 loading_qst_num = qst_num;
23145 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
23146 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
23147
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if (!is_ci())
23148 loadquest_report = report;
23149
23150 832 auto start = std::chrono::steady_clock::now();
23151 832 zprint2("Loading qst: %s\n", filename);
23152 832 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
23153 832 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
23154 832 zprint2("Time to load qst: %d ms\n", load_ms);
23155
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if (ret)
23156 zprint2("Error: %s\n", qst_error[ret]);
23157
23158
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(show_progress)
23159 {
23160 if(ret)
23161 {
23162 box_out("-- Error loading quest file! --");
23163 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
23164 box_end(true);
23165 }
23166 else box_end(false);
23167 }
23168
23169 832 load_tmp_zi = NULL;
23170 832 loading_qst_name = NULL;
23171 832 loadquest_report = false;
23172 832 loading_qst_num = 0;
23173
23174 832 zapp_reporting_set_tag("qst.author", Header->author);
23175 832 zapp_reporting_set_tag("qst.title", Header->title);
23176 832 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
23177
23178 832 return ret;
23179 }
23180